Jump to content
  • Advertisement

Archived

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

ViPeR007

tracking?

This topic is 6769 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!