Examples of two collision systems are Axis Aligned Bounding Box and Oriented Bounding Box. We would use OBB as it is more accurate and it works with any level.
Collision hulls should match the mesh as accurate as possible. Although 3DGS does not provide the exact shaped hull, we still can make use of multiple small hulls to fit the mesh. These are organised using hierarchical bounding volumes like OBB trees.
A problem to take note here is when the object move faster than the frame rate would result in missing frames. Furthermore, it might result a missed collision detection when the two objects overlap over a certain range.
There are different intersection tests for different objects. We would choose the appropriate tests for the appropriate objects. For example when a bullet hits the wall, the plane-ray intersection test is executed.
Here are example codes of collision detection in Lite-C,
Referenced from Lite-C Workshop 18 entity movement:
Moves object in the X and Z axis,
c_move(me, nullvector, vector(15 * time_step, 0, 4 * time_step), GLIDE);
Points and move object towards relative direction with wind resisting in Y axis,
c_move (my, vector(3, 0, 0), vector(0, -1, 0), GLIDE);
Points and move object towards relative direction while pulling object in Z-axis,
c_move (my, vector(5, 0, 0), vector(0, 0, -2), GLIDE);
Points and move object towards relative direction,
c_move (my, vector(15 * time_step, 0, 0), nullvector, GLIDE);
As presented, by executing the c_move instruction, collision detection is automatically in play.
Recent Comments