Game Development Community

Collision bug

by Edward Gardner · in Torque Game Engine · 03/13/2002 (6:37 am) · 13 replies

Ok, it's a know and somewhat expected thing. And it actually is 2 different things :)

1) Collision of a vehicle model with a DEAD player causes a crash to desktop for the server. Makes sense, the player.cs is server side and I THINK the bounding boxe on the player gets deleted on death. My problem is I don;t SEE where it gets deleted in code or script and my eyes started to bleed when I started debugging the C++ (though, it's sorta expected behavior, so not sure I can call it a "bug").

2) This one is less certain, or it may be a couple of things. When I collide a vehicle with DIF objects at high speeds or odd angles, I get a crash to desktop. Same thing if I SLAM a vehicle in the ground. Now, the slamming I can handle, that is an overspeed thing, I just need to slow the vehicle's max fallign speed down (is there such a thing as a terminal velocity in this engines physics?), but the other thing has me stumped and I am not sure I can consistently reproduce it. It COULD be bad collision meshes on the vehicle, id could be something in code, it could be something in script.

Anyone have any insight on either of these? The guys on IRC are getting tired of seeing me type about this, so I thought I would pester the general population.

#1
03/14/2002 (3:33 am)
For your first problem here is the correction :
void Vehicle::damageQueuedObjects(const F32 collisionVel)
{
.....
   for (CollisionTimeout* ptr = mTimeoutList; ptr; ptr = ptr->next)
   {
      SimObjectPtr<ShapeBase> safePtr(ptr->object);
      SimObjectPtr<ShapeBase> safeThis(this);
      if( bool(safePtr) ) onCollision(ptr->object);
      ^^^^^^^^^^^^^^^^^^^add this if statement
...
It will solve your problem. BTW, it crashes because you set the ptr->object to NULL when the player is dead (look in player.cs), but you can still collide on the corpse. This little hack is maybe not the correct solution.

I had the second problem too, but I didn't solve it for the moment. Nevertheless, I have some thoughts on how to correct it : need time as always ;)

Frank
#2
03/14/2002 (1:38 pm)
Hmm, that still gives me the collision error.

I'll keep hunting it down.

Where in script is it doing that set to null bit? I must be blind...
#3
03/14/2002 (1:48 pm)
From memory when player dies there is something like client.player = 0; (it's really from memory and as I'm not using that piece of code...)

Concerning your bug, check player.cc also and you may need to make exactly the same correction I propose in that source file.
#4
03/14/2002 (2:04 pm)
Thanks for the tips :)
#5
03/14/2002 (3:33 pm)
Yep, there are a handful of problems that occur with collision on the player's model once you've died.

I haven't messed with vehicles, but there's a similar problem with explosions and impulses on dead objects. Since there's no "real" object to refer to it gives an error message. What's wierd is that it still will fling the object!

Oh well, at least my error isn't fatal hehe.
#6
03/15/2002 (6:50 am)
Hmm,

Several attempts at that fix failed for me.

And I can't find a corresponding function in player.cc (the one in vehicles is the damagequeue function). So, I am GUESSING that Franks fix gets rid of some of the problem, but the specifics of colliding with the dead player is still a mystery to me :)


Having a head cold isn't helping :)
#7
03/16/2002 (5:41 pm)
I am getting a similiar error with collisions of vehicles and items.

If a hovervehicle collides with an item I get a crash 100% of the time. A wheeled vehicle only seems to crash if the wheels actually collide with the item though.

I was using the default car body model as the hovervehicle btw and the item did have a collision mesh on it.

Anyone have any idea about this?
#8
03/18/2002 (4:25 am)
Ok, so there I was, screaming at my compiler, harrassing people on IRC, and generally being in bad temperament. Tried Franks fix, no dice. Josh and I poked at it for a few last night and commented out some stuff, no dice. Then I went to bed.



I was remembering someone had this problem with their pilots getting killed, then the dead body colliding with the vehicle, then the engine crashing.

Hmm, I thought to myself, I don't actually HAVE that problem with my flyers.

EUREKA!

I hide my player onMount like so:

if (%vehicle.getDatablock().mountVisible[%node] == 0)
{
%obj.startFade(0,0,true);
}

Then unhide him when he dismounts like so:

if (%vehicle.getDatablock().mountVisible[%node] == 0)
{
%obj.startFade(0,0,false);
}


But if he is killed while flying, he never unhides, BUT HE ALSO DOESN'T CAUSE THIS IPF AND CRASH THE ENGINE.

Now, I wouldn't have noticed this, but yesterday, I was goofing around with an open topped jeep (thank you vincismurf) and had some testers doing jeep races. Of course, the jeep passengers had tommy guns, and much mayhem ensued.

Now, open air jeeps look right silly with invisible drivers, so, I changed the flag in the datablock to let these guys see each other and BLAMMO, as soon as I get a casualty, engine dies (btw, this IPF is only on the server, the clients just hang, but can exit the server and rejoin once the server has recovered).

Ok, so my thinking is a hack fix to prevent the crash is to do that object fade and remove the player till I hunt this down....

Unless anyone has any suggestions?

Oh, and this dream sequence won't end, I'm still asleep near as I can tell.
#9
03/18/2002 (12:34 pm)
That sorta fix wont help me unfortunately as the game I am working on dosnt have "players" driving the vehicles as such.

I need to collide vehicles with powerup items as part of the game play
#10
03/18/2002 (12:47 pm)
as for your power ups, I reexported all my shapes with collision and I don't have that problem.

Are you sure the items aren't still read-only and the exporter just isn't telling you it's not overwriting them? Milkshape seems to do that to me sometimes.
#11
03/18/2002 (2:01 pm)
Yeah I run into powerups, buildings, and other vehicles all the time :) and don't seem to havethe level of crashing problems we use to.
#12
03/21/2002 (11:30 am)
HAHA!!!!

in vehicle.cc

in the function:
void Vehicle::findCallback(SceneObject* obj,S32 key)


Comment out this line:
//vehicle->queueCollision(static_cast(obj));
and put a return; in there.

Crash be gone :)

Unless someone tells me what mayhem this causes :)
#13
12/04/2005 (6:30 am)
Incase anyone else still needs this, the solution to enabling collisions with corpses is commenting out these lines in player..cc at the top of Player::castRay

if (getDamageState() != Enabled)
return false;