- Home /
Effective 2.5D Seeker Missiles?
Hi,
I've been working on a "2.5D," physics game.
The current challenge is getting realistic player seeking missiles.
The player is, lets say a rocket, and is controlled with ridged body gravity, then a key press triggered relative constant force for thrust, along with rotation for changing direction.
For the seeker missiles i started by making them look at player for direction and the just a transform forward vector for speed. But the results were very unrealistic, ugly and just not fun to play - you are dealing with propulsion, gravity and pitch. But these missiles don't follow these rules - so then i lowered the vector speed, added ridged body gravity, and a constant speed thrust like the player has (removing all the vector speed made the missiles completely erratic.)
This produces very realistic looking missile movement, however, because of this fight between transform scripted movement, and physics calculated movement, it has made it pretty jerky, the "look-at" is very sharp, and jitters as it turns, and the trail render is very sharp and jittered aswell.
What i would really like is smooth rotation (with a buffer to limit it from making super sharp turns) and keep this realistic movement but without the nasty side effects.
Can anyone suggest a more efficient & proven way of doing this?
Any help would be very appreciated,
Thanks.
-G
Answer by syclamoth · Nov 30, 2011 at 12:52 PM
Have you looked at Quaternion.RotateTowards? It seems like it does exactly what you want, here. Combine it with some kind of interpolation, and you're set!
Cool thanks! - That sounds perfect for correcting the rotations. - Any thoughts on a way to combine the constant speed/ridged body physics with the transform.vectors more smoothly? Or a way of faking the missiles air slipping through code alone?
That's a tricky one, to be honest. You want to be careful when directly interacting with rigidbodies like that- they go erratic if you try to change them in the wrong way. On the other hand, this is basically what missiles in real life have to do- look up some rocket guidance algorithms, and see if you can implement them in your game world!
Thanks for all your help Syclamoth, Should be plenty to work with now. Was hoping there would be an obvious simple trick to get it working, but this should work about as-well with a bit of trial and error coding. Cheers! =D
Just thought of a good way to get this working, going to write it here so that i don't forget. XD
once i set up the Quaternion.Rotate properly to limit angle change speed and acceleration, i will also add a detector to send messages to my constant force controller in order to set the thrust.
For starters this will be something like,'IF angle change detect <= 5 degrees' - 'thrust equals 100%,' 'IF angle change detect >= 5' - 'thrust equals 10%' - And gravity will still be controlled by ridged body gravity preset.
This should remove the need for a vector speed, and give very realistic and smooth movements, and in much the same style as that of the player.
Cool, thanks a ton Syclamoth!