Monday, December 5, 2011

Alignment

In my few spare time i've tried to consolidate one big task that i wasn't able to finish in the previous years: a way to align, softly, an object to any direction.
I need this for a lot of different situation: my ship has to align to the station, when i activate the autopilot, an enemy ship has to align to my position for reach me, an homing missile has to follow my target, and so on.
Previously i tried to solve it using normal euler rotations but it was a mess, and i've left this way.
The solution is: quaternions and SLERP.

It's not my intention to boring you with maths details (but you can ask me if you want), i prefer to show you the result: a ship floating into space try to align with my position:



you can notice that when i move, the ship follows me, in all positions.. also when i go up or down.

..and you can see also (for a brief moment) my ship firing a laser :)

No comments: