Sign in to follow this  
Magogan

Collision detection in a voxel game

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

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