Game Development Community

Scheduling delete crashes torque?

by Kirby Webber · in Torque Game Engine · 01/03/2006 (6:56 pm) · 3 replies

I have an AITurret mounted to a vehicle.

Obviously, before I delete the vehicle, I want to delete the turret.

function TurretData::onDestroyed(%data, %obj, %prevState)
{
   // Delete the turret
   %obj.schedule(100, "delete", true);
}

What's strange is that this code, as-is, works but generates a "wrong number of arguments" error in the console - though the turret disappears.

Now, the error is generated because the delete method isn't looking for any arguments. The correct syntax would be:

%obj.schedule(100, "delete");

The problem is that when I run with this "correct" syntax, the engine crashes.

Any thoughts?

#1
01/03/2006 (7:08 pm)
Nevermind...
#2
01/03/2006 (7:26 pm)
Nevermind that nevermind.

The issue was not what I thought it was.

As a test, I removed the call to delete my vehicle and stripped the turret::onDestroyed function to nothing:
function TurretData::onDestroyed(%data, %obj, %prevState)
{
}

Turns out, that simply flagging the turret state to "Destroyed" is sufficient to see them removed/ deleted.

At this point I could die endlessly with no crashes - but corpses everywhere. =\

When I add the %obj.schedule(1250, "delete"); line back into my vehicle ::onDestroyed function, the engine crashes - not necessarily the first time, but within three deaths. =\
#3
01/03/2006 (8:19 pm)
Got it.

Forgot a call to delete my turrets in onRemove().

Once I realized that was still there, I ripped it al out and everything seems to be working as intended.