Jump to content
  • Advertisement
Sign in to follow this  
suliman

collision-box rotated?

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

Hi I have vehicles that i wish to collision check vs projectiles. A vehicle has these properties: int2 pos; //the game is in 2D int2 size; //width and height float rot; //in radians So its easy to check the projectile (considered a simple point) vs a non-rotated rectangle but as my units turn how do i handle this? Thanks Erik

Share this post


Link to post
Share on other sites
Advertisement
Imaging rotating the entire world about the 'pos' of the vehicle, by the negative of its 'rot'. Q. Where will the corners of the vehicle end up? A. Aligned, again (we cancelled out the rotation), and still centered on the 'pos'. Q. Where will the projectile end up? A. As if we had translated the centre of the vehicle to the origin, performed the rotation and then translated back. Q. Is the original projectile inside the vehicle? A. If and only if the moved-via-rotation projectile is inside the rotated vehicle (which you can check easily), since rotation and translation do not affect this property (you can turn a piece of paper whichever way you like or slide it around to anywhere, but crossed lines on the page are still crossed, and uncrossed lines are still uncrossed).

Share this post


Link to post
Share on other sites
he?
maybe you know of a tutorial that goes through this step by step? Ive googled a bit but finds only tuts on specific game engines.

thanks
E

Share this post


Link to post
Share on other sites
oh maybe i have an idea now... I could use the code I finally got working for offsetting I roteted body and just do the other way around... Maybe that was what you suggested :)

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!