• entries
45
44
• views
51312

# Simple sliding collisions

846 views

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.

Note:

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.

There are no comments to display.

## Create an account

Register a new account