- Home /
3D spaceshooter : targeting system
Hi guys,
On many 3D spacheshooters there is a marker in front of the ship you are trying to shoot, like in freelancer (the red cross):
It's the point you need to aim to have the most chance of hiting the ship (if it don't change his trajectory) calculated with the direction of the ship, its speed, and the speed of the bullet. (I suppose)
I understand the principle (I suppose. Again. :p ) But I have no idea what the exact mathematical formula is.
Can you help me?
Thanks a lot :)
Answer by tet2brick · Aug 23, 2012 at 09:11 AM
Hi again
I've managed to put that in place as I wanted, so first of all, thank you sir. :)
But there is two small problems.
To calculate the "Aim point" I need to put a rigidbody on the target ship, the bullet and the shooter. So I need to move them by adding forces (so the object can have a rigidbody.velocity value)
The first problem is that when the bullets collide with the target ship, the ship goes spinning maddly, even if I use a highest mass for the ship.
The other problem is that I find it more difficult to move the ship with the engine physics than with a simple transform.position or transform.translate. Is there a simple set of functions to move object with the physic engine OR is it possible to adapt the class you gave me to use it with function like translate?
I've tried to calculate a velocity based on the current and last position, but even with time.deltatime, but the numbers returned change a lot each frame so the visor is jittering maddly.
Thanks again :)