Game Development Community

Throwing people from their vehicles when they hit something

by Neil Marshall · in Torque Game Engine · 06/10/2003 (11:19 am) · 6 replies

I'm trying to throw the player from their vehicle when they hit anything at high speeds.

I thought I could just put an unmount command in the onCollison if the speed was greater than some value, but the event only seems to fire when I run the character into the side of the car, not when the car hits something.

Does anyone know how to get a collision event to fire when you run into objects or steep landscapes?

#1
06/10/2003 (11:37 am)
.. the vehicle's onCollision method should fire when it hits something no?

are you using the vehicle onCollision or the player?
#2
06/10/2003 (11:48 am)
Check the collision mask. I bet the onCollision for the vehicle only triggers when it hits certain things. Do NOT (however) add terrain to the mask without modifying it somewhat, because the vehicle is always colliding with the ground. (Wheels) You should be able to (and it should realize) when it runs into interiors or static shapes.
#3
06/10/2003 (12:20 pm)
Here is my code. Unfortunatly, the comment doesn't seem to be telling thr truth.

function WheeledVehicleData::onCollision(%this,%obj,%col,%vec,%speed)
{
   // Collision with other objects, including items
   echo(":: That hurt" SPC %speed);
}

I'll look into the collision mask. I have to figure out what they are first though, know of any documentation?
#4
06/10/2003 (1:14 pm)
@Pat: Not true :)
The vehicle is almost NEVER touching the terrain unless it flips. WheeledVehicleData::onCollision will never be called for terrain if it's in the mask, but WheeledVehicleTire::onCollision would... they are different objects :)

@Neil: I'm not sure if by default onCollision should work, but as Pat said I would check the Collision mask, it should be defined in the wheeeledvehicle.cc file. It's a mask (doh!) that defines which types of objects the class has to colide with. It's a binary number so you can compare it using binary operations.
#5
06/10/2003 (1:17 pm)
Actually I took a quick peak and found this in the top of the file:
// Collision masks are used to determin what type of objects the
// wheeled vehicle will collide with.
static U32 sClientCollisionMask = 
      TerrainObjectType    | InteriorObjectType       |
      PlayerObjectType     | StaticShapeObjectType    |
      VehicleObjectType    | VehicleBlockerObjectType |
      StaticTSObjectType;
So that's the collision mask for the wheeled vehicle... but... now that I see this and it SHOULD work.. I remeber there's a bug in the WheeledVehicle code... the body of the vehicle has no collision at all.... what's colliding are the wheels... so yes... you can go through someone or something like a light post or something like that. I'm not sure what this bug was about but If anyone has any information on remember such bug be sure to jump in.
#6
06/10/2003 (1:17 pm)
Oye. I'm wrong. Good call on that. :-P