# How can I set hyperbolic path?

I have a tower which should shoot arrows on enemys.
I have the start location of the arrow and I have the enemy location.
How can I set a path for the arrow?

(The game is 3D)

Maybe you can use curve:

What mouvement do you want ?

Is your ennemi is in mouvement ?

Is your arrow has a constant time to travel ?

I do not see how I curve will help me.
-What do you mean by whay movement do I want?
-The enemy position can be dynamic but it does not matters to the arrow. It needs to reach to static point that sets at run time.
-No.

If you have physic enable your arrow you juste have to set an impulse to your arrow at start, then let gravity do the rest.

Yes, but I have a tagert to be reached. Which means that I need the calculate the specific initial speed of the arrow. I do not know how to do that.

Ok, i can’t help you on that. sorry. You will need value as friction and mass of your arrow. I m not good enough in mecanic. If i was you i would use something easier: disable physic and use SetActorLocation (), that is why you can use Curve.

Hey Darkstorm,

Turns out ol’ Isaac “Apples Hurt” Newton can help you here. One of Newton’s kinetic equations is:

``````D = Vi * t + 1/2 * A * t * t
``````

You know the distance (you have a start and end point), you know the time (assuming it’s constant), and you know the acceleration (gravity and some forward speed). Given all that, we can re-arrange this equation to get Vi.

``````Vi = (D - (0.5 * A * t * t)) / t
``````

So, let’s start filling in some of those parameters.

``````// Let's just assume we have a "Launcher" actor which is where our arrow spawns from, and a "Target" which is just some 3D point in space.
const float arrowSpeed = 1.0f; // This is just some constant for our arrow acceleration. Since arrows don't have motors, just set this to 1.0f.
const float flightTime = 1.0f; // Reach our target in 1 second.
const FVector& arrowStart = Launcher->getActorLocation();
const FVector& arrowEnd = Target;
const FVector distanceVec = arrowEnd - arrowStart;

// Construct our acceleration. This assumes there's no Pitch/Roll to the "Launcher" actor.
const FVector& arrowDirection = Launcher->getActorRotation().Vector().SafeNormal();
const float gravity = GetWorld()->GetGravityZ();
const FVector acceleration(arrowDirection.X * arrowSpeed, arrowDirection.Y * arrowSpeed, gravity);

// Solve for Velocity
const FVector velocityInitial = (distanceVec - (0.5f * acceleration * flightTime * flightTime)) / flightTime;

// Apply the velocity to your arrow and away it goes!
``````

I don’t have a sandbox setup to test this, but I’ve written similar code and this approach has worked well for me in the past - hopefully it’s what you’re looking for. Otherwise a quick google of “Projectile Motion” can give you numerous approaches and walkthroughs depending on the behavior you are looking for.

Good luck!

Thank you it works!

I have just needed to add: velocityInitial.Z = 0;