Sign in to follow this  
Celeborn09

Ray and Rectangle Collision

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this