# Collision detection in a voxel game

This topic is 1327 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi,

I already have a collision detection in my voxel game, but I think I am doing it wrong. All voxels are AABBs and the player is also, I try to move the player first in direction with gravity, then in direction without gravity, then in direction without y, then repeat these three steps for direction.x=0, direction.z=0 and direction.x and z both 0. The first movement that is not (0,0,0) because of collision with a voxel is the resulting movement I apply to the player. Then I repeat this if there is some time left for movement.

For checking the collision I compute the distance between the voxels by doing a ray vs. AABB test with one ray per vertex of the AABB cube (in both directions, from player to voxel and from voxel to player).

If moving towards a wall, I move the player up (by (up to) 0.6 meters), then forward (as far as possible) and then down again (as far as possible). So it will walk upstairs if there are stairs.

But I wonder what I could do if it gets more complex than just AABBs. I think more complex shapes are not possible with the current approach. Or I am just to stupid to know how this could be done.

And is there a best approach for sneaking (stopping at an abyss instead of continue walking and falling down)?

(Sorry for bad english.)

Edited by Magogan

1. 1
Rutin
67
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633420
• Total Posts
3011790
• ### Who's Online (See full list)

There are no registered users currently online

×