# How do I get X speed in "over time"

Hey guys,

I was wondering if anyone know how to get X speed depending on distance instead of “over time”?

I don’t understand fully tho, I’m a noob to UE4 so i apologize.

But I understand making a HookSpeed float variable, and the HookVelocity vector variable, so thats okay.
Then I don’t understand the rest(sorry), do you mean world location or where do I find WorldPosition?
and then I don’t understand the rest at all.

Regards

i updated my answer, every time i said position, i meant location.

if you take a destination vector, and subtract a current location, you will get a vector pointing from your current location to the destination. normalizing that vector shrinks it to a length of 1, but it still points in the same direction. this allows you to multiply the vector by a speed variable to control its speed in any direction.

multiplying by DeltaTime from the EventTick allows you to keep things frame rate independant, so whether the game is running at 30 frames a second or 95 FPS, things will move at the same speed.

Thank you again Omnicypher, I am very gratful for the time you are taking to help me, but I still don’t understand how to do this part tho: “during EventTick, GetWorldLocation of the Actor , add (HookVelocity x HookSpeed x DeltaTime) to the Location vector, then use that to SetWorldLocation of the Actor.”, am I even close?

before setWorldLocation, you need to add the current WorldLocation to those numbers you multiplied, so when you move the location, it moves relative to its current location, instead of setting its absolute Location relative to the origin of the world.

add an eventTick, and use its DeltaTime output pin instead of your DeltaTime float variable, and use the eventTick to drive the getLocation and SetLocation part, because you want it to move every frame.

you may also want a boolean to keep track of whether the hook should be retracting. so when the HookLanded event fires, it sets the velocity and sets bHookRetracting to true. once you get close to the target, you could set bHookRetracting to false, and in the EventTick, you can use bHookRetracting in a branch node to decide if the Hook should be retracting.