Game Development Community

Limiting Vehicle Movement

by GarageGamer · in Torque Game Engine · 08/08/2003 (1:14 pm) · 2 replies

Hey guys
I'm using a custom hover vehicle in my game, that moves in X-, Y-, and Z-axis.
I need apply "boundaries' to my hoverVehicle movement, such that .....
if my hover vehicle's origin is 50units above the ground, it should move :

50units on +ve and -ve x-axis
50units on +ve and -ve y-axis
50units on +ve and -ve z-axis

as soon as it touches 50units(on any axis), it must stop.

any help wold be great

thanks in advance

#1
08/10/2003 (8:17 pm)
Look in the updateForces section (if you still have it) and check the position of your vehicle against your limits. Then zero out force and linVelocity in mRigid.

You should make sure that it also happens clientSide if you can otherwise you get weird "ghost" movements where prediction is happening.

- Brett
#2
08/12/2003 (10:26 am)
Thanks Brett,
I tweak the UpdateForces in hoverVehicle.cc

void HoverVehicle::updateForces(F32 /*dt*/)
{
.....
.....
....
//for x-axis
if(mRigid.linPosition.x > 128.0f)
{
mRigid.linVelocity.x = 0.0f;
mRigid.clearForces();
}
else if(mRigid.linPosition.x < -118.0f)
{
mRigid.linVelocity.x = 0.0f;
mRigid.clearForces();
}//18.723 -406.125 163.836

//for y-axis
if(mRigid.linPosition.y > -436.1f)
{
mRigid.linVelocity.y = 0.0f;
mRigid.clearForces();
}
else if(mRigid.linPosition.y < -376.0f)
{
mRigid.linVelocity.y = 0.0f;
mRigid.clearForces();
}

//for z-axis
if(mRigid.linPosition.z > 193.0f)
{
mRigid.linVelocity.z = 0.0f;
mRigid.clearForces();
}
else if(mRigid.linPosition.z < 33.0f)
{
mRigid.linVelocity.z = 0.0f;
mRigid.clearForces();
}

mRigid.force = force;
mRigid.torque = torque;
}

i did the above 'tweak' ... but the vehicle isn't stopping at the limits(boundries)

any idea guys ... thanks in advance