Collision detection 3d and 2d

How to make it so that the model does not go beyond the intended boundaries?
How can I do the collision detection?


For 2D I would use a second texture solid colour for representing areas character cannot traverse and transparent for areas player can move, then use per pixel collision to determine if any of the none transparent pixels of the player texture overlap a none transparent pixel of the second texture signifying they hit bounds.

For 3D Id probably use bounding boxes to line the edges of the path then check for intersection with the players bounding box to determine if they hit the bounds.

1 Like