Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Simple sliding collisions

Sign in to follow this  
Norman Barrows


Simple sliding collisions

simple sliding collisions:

for AABBs:

1. start by calculating how much to move the player as usual:

dx = player.speed * sin(player.yr)
dz = player.speed * cos(player.yr)

2. apply dx and dz, and check for collsions as usual.

3. if a collison is indicated:

3a. apply JUST dx and check for collisions.

3b. apply JUST dz and check for collisions.

3c. if collision in dx but not dz, move the player by dz.

3d. if collision in dz but not dx, move the player by dx.

3e. if collisions in both dx and dz, don't move the player.

3f. if collisions occur in neither dx nor dz, don't move the player.

note that this may also work for types of collision checks other than simple AABB.


case 3e - collisions ahead, left, and right - is when the player is facing into some sort of corner (continuous or otherwise).

case 3f - collisions ahead, but not left or right - is when the player is facing a telephone pole or similar object.
Sign in to follow this  


Recommended Comments

There are no comments to display.

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

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!