Sign in to follow this  
Zerod

Collision handling with Rotated Rectangles

Recommended Posts

Zerod    100
I am about to develop a little 2D game. The perspective is top Down like, so you can only see the Had of the player. You can move the Player with WASD and he and his Collision Box Rotates, in the Center of the Player, to the mouse Position. In the World are some rotated Walls, by which the Player can collide with.

I have a function for the Collision detection with 2 rotated Rectangles, but i don't know how to handle it.

Has someone a function, with takes the 2 rotated Collision boxes and gives me the right position back. Or has someone an example for such a problem?

I need some help.

Share this post


Link to post
Share on other sites
haegarr    7372
At least 3 reactions can be implemented.

* Set the mobile collider back in opposite direction of its original movement until the collision is nullified, and cancel the current movement. This method let the collider look like avoiding collision simply by stopping.

* Set the mobile collider back in direction perpendicular to the obstruction until the collision is nullified, and cancel the current movement. This method let the collider look like it really hit the obstruction.

* Set the mobile collider back in direction perpendicular to the obstruction until the collision is nullified, and continue the movement only with the component parallel to the obstruction's shape at the location of contact. This method let the collider slide along the obstruction.

All methods above can be combined with a correction of the line of sight.

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