Game Development Community

Getting an AIWheeledVehicle to stop

by John Cooney · in Torque Game Engine · 11/10/2005 (3:12 pm) · 4 replies

I've got an AIWheeledVehicle that I am setting up to follow its path, and engage the player if he/she gets too close. My problem is that I need a way to stop the vehicle, if the player stops. As it stands right now, the vehicle will drive right over the player, then turn around and try to get back to that point behind the player, thus driving in tight circles.

I've tried everything I can think of, I've tried the "stop" command, I've exposed the "DisableMove" variable, I've set the velocity to "0 0 0", I've exposed the "Braking" variable, I've massively increased its mass and tried to bring maxwheelspeed down to nothing. None of these seem to stop the vehicle.

I get the feeling that after I make these changes, they are all overwritten in the AI code, but I can't figure out where that is.

Can someone help me stop this thing? :P

#1
11/10/2005 (3:26 pm)
One way to do it is to setMoveDestination to your current position and set some sort of flag to make sure that the onReachDestination callback doens't try to move you again. Here's some pseudo code:

// Right after we decide that we want to stop
  %vehicle.path = "";  // This will cause onReachDestination to stop setting new destinations
  %vehicle.setMoveDestination(getwords(%vehicle.getTransform(), 0, 2), true); // This will tell the AIWheeledVehicle code to move to it's current position!

Hope that helps.
#2
11/12/2005 (6:08 am)
Thanks. I tried that, and it did seem to slow him down. In fact, I think it makes the vehicle try to turn around (having rolled past that point).

I think my problem might be that I'm setting the "disable move", and somehow, that stops the car, but not the tires. I know that sounds wierd, but I think that's it.

If I ram the car, I can get it up off the ground, hanging in midair with wheels spinning. "disable move" makes the car physics stop, but it doesn't make the wheels stop. Maybe if I totally drop the wheel friction . . .
#3
11/12/2005 (8:29 am)
John: I've had this problem too, and that sounds correct, not 100% sure though?
#4
11/12/2005 (9:32 am)
Ahh, you might want to check for DisableMove in AIWheeledVehicle::updateMove (I think) and set move->y to 0.