Skip to main content
GameDev.net gamedev.net
🔒 Locked

tracking?

Started by ViPeR007 Apr 6, 2000 at 8:30 PM 0 replies 650+ views
Original Post
ViPeR007
ViPeR007
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
Zipster
Zipster
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!!!


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.