Jump to content
  • Advertisement
Sign in to follow this  
bobsaget

An xna tutorial i need to find?

This topic is 3777 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

I am trying to find a tutorial on xna that answers a basic question that I can't complete. My goal with this is to have a sprite rotate(top down view of a person) and launch a sprite from its center. I have that part but my only problem is that I want the sprite to launch from the front of the sprite no matter what direction it is turned(So it can launch in a 360 degree way). I searched google and everywhere else and could not find this? Any ideas. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Are you talking about like shooting a sprite bullet from a ship sprite? For example, if the ship is aiming North and turns left and is aiming SouthWest you want to be able to shoot where the sprite is pointing (to the SouthWest)?

Share this post


Link to post
Share on other sites
Yah, like if the is vertical and turns left I want the sprite to launch left instead of forwards. But like you said with some greater degree of choice like southwest instead of just south or west.

Share this post


Link to post
Share on other sites
You'll have to take the ship's rotation into account. The rotation is defined by a Matrix, so you should be able to just multiply the rotation matrix by a unit vector pointing forwards (i.e. Vector3(0,0,-1) ). This calculation will give you a forward vector in the current direction of the ship. The final step is to just have the bullet travel along that forward vector.

Edit:
Sorry, I just realized that you were referring to a 2d sprite (it's a 3D development habit). You should be able to apply the same principle of having a, now, 2d vector pointing in the direction of the positive y-axis, and use that as the forward vector.

Hope it helps!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!