tags:

views:

103

answers:

1

I have a player sprite (playerTexture) and a crosshair sprite (crossTexture) in my game. I need to make the player sprite always face towards the crosshair.

Does anyone know how to do this? I have tried doing it myself but the math involved boggles my mind. I know there's a rotation parameter in the spriteBatch.Draw() method but I'm unsure how to use it.

Thanks!

+1  A: 

rotating a sprite to following another sprite is mostly just triangle math. I was going to try and type up a good explanation, but then i found this posting - which includes pictures to help you along the way, which hopefully will help you understand what's going on and what you need to do.

http://www.berecursive.com/2008/c/rotating-a-sprite-towards-an-object-in-xna

David Larrabee
In the end I looked at some samples on the XNA website and there was a pre-made project that demonstrated what I want. Although I'll probably go through the tutorial you found so I can learn exactly what's going on. Thanks! :)
Joshua