Archived

This topic is now archived and is closed to further replies.

ViPeR007

tracking?

Recommended Posts

Does anyone know a good way of having an object (like a turret) track another and adjust its frames accordingly. Like right now I have it working but its a really long and annoying way. Its just: if(PlayerX > (EnemyX - 50) && PlayerX < (EnemyX + 50)) Enemy = SetFrame(4); And so on and it gets really long when you do it for 16 frames. Is there a better way of doing this? Thanx, ViPeR

Share this post


Link to post
Share on other sites
Asign a angle range to each frame (i.e the range of angles that a frame can be used for), and use cos and sin look-up tables to calculate the relative angle of the player, and then search for the appropiate frame.

WARNING!!! WARNING!!! WARNING!!!


This may not be better or more efficient!!!

WARNING!!! WARNING!!! WARNING!!!


Share this post


Link to post
Share on other sites