5

I have a big array of voxels, a la Minecraft. The player/enemies are in this grid. I have no idea how to go about doing this type of collision detection. Note, this is NOT dynamic movable object vs. dynamic movable object, this is movable object vs. stationary ground/wall/ceiling.

I have no problem with detection, its the response that I do not know how to do.

What I have to work with: Player position, velocity, and boundingbox, and a array of 1x1x1 voxels surrounding the player.

Ben Parsons
  • 1,425
  • 1
  • 14
  • 30
  • 1
    You might have a bit more luck asking on http://gamedev.stackexchange.com/ – Holger Jan 23 '12 at 21:06
  • Am I allowed to just copypaste this into a new question there? –  Jan 23 '12 at 21:08
  • @khyperia: I've flagged it to be migrated by a mod. – George Duckett Jan 23 '12 at 21:09
  • I'm reluctant to move this as this question is NARQ here and there. Please show some code which shows the problem or at least, the structures that you are working with, and if it's a better question, then we'll migrate (flag again). – casperOne Jan 23 '12 at 21:23

1 Answers1

6
  • Calculate the dot product of the player's velocity and the unit surface normal of the colliding voxel (pointing outward).
  • Scale (multiply) the unit surface normal by this value.
  • Subtract your result from the player's velocity.

This will give you the "slide against the wall" effect that most games employ (without any problematic trigonometry)

Drew Dormann
  • 59,987
  • 13
  • 123
  • 180
  • What about telling which direction the player should go, IE which surface plane is the player intersecting? The top, side, what? –  Jan 23 '12 at 21:21
  • If you're having trouble determining that, I recommend posting a new question. Some may be able to post a better answer than I could. – Drew Dormann Jan 23 '12 at 21:24
  • 2
    Just an addition, if you also have a different multiplier, on top of the dot product, per material in the voxel, then you're now modelling friction and can have more slippery or more rough blocks. – Cave Dweller Aug 26 '15 at 15:45