Have one Object Follow the Approximate Path of another

I am creating an air combat game and I need to create one script that I cant get my head around. Its very hard to explain so forgive me if its hard to get.

The game has a missile lockon system that predicts the movement of an aircraft and intercepts their path. However,we’ve found that its to easy to confuse the missile by doing constant barrel roles. What we’ve come up with is to have the missile fly towards a target marker that replicates the aircrafts movement except does not have as sharp of turns. Once it stars getting closer, it will start to focus more on the aircraft so it can hit.

the target marker is basically the aircrafts movement except not as sporadic. So if the aircraft is doing barrel roles in a cylindrical path, the target marker may just travel straight.

We’ve tried just having the marker lerp towards the aircraft but it lags behind a great deal. We need the target marker to lerp towards the aircrafts when it makes turns but is somewhat parented to the aircraft so it does not need to follow behind.

I belive we need an object that can be parented to the aircraft and stay at 0 on its local Z axis while being able to lerp towards it on its other local axis.

Thank you

So how are you predicting the path of the aircraft?

Are you just gathering the positions of it over time and then just interpolating off of that forward. And this is why the barrel screws with it… because the path not only has a forward motion but a spiral motion along that forward, giving a side to side path which causes jitter in the prediction?

If this is the case, normalize the position when tracking them.

You can do this by taking the forward vector of the ship… it can be assumed that the ship is going to head in the direction it’s facing. As you predict the path, compare this to the ships forward, and average them to remove the jitter.

I am using a missile script package from the Unity store so I don’t know much of how it works.

There’s no jitter so to speak. The missile moves fairly smooth. Its prediction is pretty accurate its just not smart enough to recognize repeated flight paths (I dont blame it since that would be alot of work). I could solve everything by just increasing the missiles turn speed but would make it to harder to evade with all other maneuvers also.

I think I can solve it by just giving the missile a target that lerps towards the aircraft while its turning, but does not fall behind the aircraft. That was the conundrum I was trying to figure out.