Jump to content
  • Advertisement
Sign in to follow this  
Magogan

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.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!