Jump to content
  • Advertisement
Sign in to follow this  
Celeborn09

Ray and Rectangle Collision

This topic is 3335 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 currently making a basic 2D game and need to determine when a ray (your sprite's laser) collides with a rectangle (the enemy). I also need it to determine which rectangle the ray collides with first and have it return to me the point where the ray and the edge of the rectangle intersect. I would like to know if there is a simple method to calculate this and what the process is for checking this single type of collision as in my game, no other collisions are taken into account. Thanks in advance for your help.

Share this post


Link to post
Share on other sites
Advertisement
Hello,


have a look at line clipping

http://en.wikipedia.org/wiki/Line_clipping

that should get you started



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!