Hey all, I've just started doing collision for my game and I would like your thoughts on how you guys do it. I'll post my commented code below but the general idea is to see if the new movement would cause any collisions and if so, sent it back so that it doesn't make any collisions.
How do you guys do it?
//Check if any movement has happened to reduce unnecessary calculations.
if( x != xOld || y != yOld || z != zOld)
{
//1 is the ID of the terrain and id is the current object id.... If hit....
if(dbObjectHit(1,id) == 1)
{
//Position it at old position
dbPositionObject(id,xOld,yOld,zOld);
}
//Else....
else
{
//Position at new position
dbPositionObject(id,x,y,z);
xOld = x;
yOld = y;
zOld = z;
}
}