Vehicle destroyed problem
by JohnT · in Torque Game Engine · 02/09/2006 (2:40 pm) · 5 replies
I have been having a problem implementing the "destroyed" mode on the BraveTree WarSparrow. I have been able to get all the emitters to work and to have the plane eventually explode after taking enough damage from hitting the ground.
My problem is that the player continues to be in the seated position once the plane is destroyed and all controls act as if he is still inside the plane and he can fly around still.
If I add the following:
function FlyingVehicleData::onDestroyed(%data, %obj, %prevState)
{
%obj.schedule(4000, "delete");
}
The program then crashes after 4 seconds. Hope someone has an idea on how to resolve this.
Thanks
My problem is that the player continues to be in the seated position once the plane is destroyed and all controls act as if he is still inside the plane and he can fly around still.
If I add the following:
function FlyingVehicleData::onDestroyed(%data, %obj, %prevState)
{
%obj.schedule(4000, "delete");
}
The program then crashes after 4 seconds. Hope someone has an idea on how to resolve this.
Thanks
About the author
#2
02/10/2006 (3:27 am)
Thanks, that appears to work. For some reason I thought that when a vehicle was destroyed that the player was supposed to die with the vehicle and would respawn.
#3
function FlyingVehicleData::onDestroyed(%data, %obj, %prevState)
{
%player = %obj.getMountNodeObject(0);
if (%player != 0)
%player.kill();
// Release the main weapon trigger
%obj.setImageTrigger(0,false);
%obj.setShapeName("");
%obj.schedule(300, "delete");
MissionCleanup.Add(%obj);
}
Now the player is ejected from the plane and everything blows up nicely. The only remaining issue is that the player goes into the standing position for the death sequence instead of falling down and does not respawn until I click the left mouse button.
02/10/2006 (4:46 pm)
OK, I think I'm getting closer on this now. What I found is that I was referencing the wrong mount point in order to gain access to my player so I could then kill him. The code looks like this now.function FlyingVehicleData::onDestroyed(%data, %obj, %prevState)
{
%player = %obj.getMountNodeObject(0);
if (%player != 0)
%player.kill();
// Release the main weapon trigger
%obj.setImageTrigger(0,false);
%obj.setShapeName("");
%obj.schedule(300, "delete");
MissionCleanup.Add(%obj);
}
Now the player is ejected from the plane and everything blows up nicely. The only remaining issue is that the player goes into the standing position for the death sequence instead of falling down and does not respawn until I click the left mouse button.
#4
02/10/2006 (5:21 pm)
I think you can probably change his animation in this instance from Standing to something else by using a setThread(); command.
#5
In case anyone down the road runs into the same problem, I am documenting my code below.
function FlyingVehicleData::onDestroyed(%data, %obj, %prevState)
{
%player = %obj.getMountNodeObject(0);
%player.unmount();
if (%player != 0)
{
%player.kill();
}
%obj.setImageTrigger(0,false);
%obj.setShapeName("");
%obj.schedule(2000, "delete");
MissionCleanup.Add(%obj);
}
What I found was if you do not unmount the player before you kill him, his death animation is somehow cancelled yet the player still turns into a corpse in the standing position. Definitely not the desired effect.
Thanks for everyone's help in resolving this.
John
02/11/2006 (1:02 pm)
Got it!In case anyone down the road runs into the same problem, I am documenting my code below.
function FlyingVehicleData::onDestroyed(%data, %obj, %prevState)
{
%player = %obj.getMountNodeObject(0);
%player.unmount();
if (%player != 0)
{
%player.kill();
}
%obj.setImageTrigger(0,false);
%obj.setShapeName("");
%obj.schedule(2000, "delete");
MissionCleanup.Add(%obj);
}
What I found was if you do not unmount the player before you kill him, his death animation is somehow cancelled yet the player still turns into a corpse in the standing position. Definitely not the desired effect.
Thanks for everyone's help in resolving this.
John
Torque 3D Owner Martin "Founder" Hoover