Move actor towards a point in line

I’m implementing a wire guided missile which follows players crosshair. I tried to implement it two different ways.

One way was projecting missiles velocity onto cameras forward vector and subtracting it from the current velocity. Problem with this one is the missile only alignes its own forward vector to match cameras forward vector. Hence flying in offset (near the crosshair) when moving the crosshair to new target.

Another way was finding the closest distance from the missile on to a line made from the cameras forward vector. This makes the missile to adjust the offset towards the crosshairs direction only resulting in a mindless wobbling.

I feel I’m not far away getting this right. But I’m clearly missing a piece here.

Can someone give pointers to right direction?

You could make your AI follow a spline path, this gives a nice smooth and clean motion rather than wobbling between points.

Here is a tutorial video on how to set it up:

Im not using AI nor I dont see any reasons why should I. I just need the missile move towards the cameras forward vector

You could do a trace line from the camera to a forward vector point i.e. 5 meters away and use this vector. Check if the Hit Result is False to be sure nothing is blocking it.

I’m sorry I didnt mention the project is first person shooter. Trace line would be no help either in this case

Im on mobile atm, but had this idea to project the missile location onto a plane defined by the camera location, forward vector being the plane normal and subtract the resultant from the velocity. I’d still need to smooth out missile’s angle when getting closer to the cameras forward vector, which I’m not sure how to do

It doesn’t need to be a FPS, you can still use trace lines from the camera location as start point :slight_smile:

That vector would need to constantly move ahead of the missile which might cause some problems.

You can check for the distance between the player and the missle by getting the Location of both, subtract them, then use a Vector Length, from the float pin <= 200 is true → move missle.

200 is reflecting 2 meters.

To avoid doing this on each tick, You could start a TimeLine from begin play and create a custom node (i.e. called RestartTimeline) and connect this to the Start execution pin. Then in the timeline add a Event Track (call it i.e. CheckDistance), add a pin by shift clicking on the timeline. Set one for example on each second (leaving the default Timeline length on 5 seconds).
Then back in the Event Graph, you should have a new output Execution pin called CheckDistance. Connect this then to the Branch that checks the distance.

From the Completion execution pin, add the RestartTimeline node you made earlier.

This results in looping the Timeline to check the distance between the player and the missle every second.

How is that relevant correcting the flight path?

Adding both methods together mentioned in the question and scaling them got me the results I was looking for.