• News

• Industries

• Learning & Support

• Community

• Marketplace

# [Help] How do i set scaling damage from a spear based on player velocity

I am very new to unreal, and would like to set up a blueprint that deals a certain amount of damage to a player based upon how fast the (self) player is moving. I have a sphere collision component and can set it up so that on collision it destroys actors, but i would like to do scaling damage. Any help would be much appreciated!!

First you need to setup the whole concept of “health” and “damage”. Actors which can take damage need a variable added to them to keep track of their health. When the health is 0, you can have them die / destroy.
When the spear collides with the actor, instead of destroying it you can “deal damage”, which essentially means “subtract from health”.
To make it scale based on velocity, you can use the “Get Velocity” node on the player, and then get the “Length” of that vector. This is the speed of the player. Then, do whatever math you want to make the speed influence the damage.

You’re also going to need to be able to cast between your spear and player blueprint, but that’s a really good thing to learn, as you will often need different BluePrints to communicate with each other.

if every player will be using the same base character or child character here’s the first option that came to my mind.

Within the spear blueprint, make a “BeginOverlap” or “On Hit” event for the spear collision component. Take the “Other Actor” node and type out "cast to the actor you want to compare. (if for some reason the “Cast to character” does not come up as an option open that character’s blueprint, type cast to *** and then copy/paste to the spear blueprint…I had to for some reason). Now from the “As ****” node drag off and “get velocity”. Then click on the blueprint and “Get Velocity (self)”. Apply damage…and somehow convert the vectors to a float or integer.

https://blueprintue.com/blueprint/gq91kxmw/

addendum: you don’t need to cast…just pull of from the “Other Actor” node and type “Get Velocity”

As Booleansphinx said. It should look something like this:

https://blueprintue.com/blueprint/po_1vn-3/