Restarting
by Edith Cowan University (#0002) · in Torque Game Engine · 05/24/2009 (3:08 am) · 3 replies
Just a quick question... our game has the option to restart when you die. The only problem is that if you don't press space (to restart) within a certain period after dying, it doesn't restart properly.
Does anyone know why this might be?
In default.bind.cs:
In main.cs:
Cheers.
Does anyone know why this might be?
In default.bind.cs:
function spaceBar(%val)
{
if($client.player.getState() $= "Dead")
{
loadMyMission();
}
}In main.cs:
function loadMyMission()
{
// make sure we are not connected to a server already
disconnect();
// Create the server and load the mission
createServer("SinglePlayer", expandFilename("./data/missions/workshop01Mission2.mis"));
// Make a local connection
%conn = new GameConnection(ServerConnection);
RootGroup.add(ServerConnection);
%conn.setConnectArgs("Player");
%conn.setJoinPassword("None");
%conn.connectLocal();
// Reset in-game controls.
PlayGui.reset();
}Cheers.
Torque 3D Owner Scooby Brown
i believe your problem resides in player.cs in this function
function Armor::onDisabled(%this,%obj,%state) { // The player object sets the "disabled" state when damage exceeds // it's maxDamage value. This is method is invoked by ShapeBase // state mangement code. // If we want to deal with the damage information that actually // caused this death, then we would have to move this code into // the script "damage" method. %obj.playDeathCry(); %obj.playDeathAnimation(); %obj.setDamageFlash(0.75); // Release the main weapon trigger %obj.setImageTrigger(0,false); // Schedule corpse removal. Just keeping the place clean. %obj.schedule($CorpseTimeoutValue - 1000, "startFade", 1000, 0, true); %obj.schedule($CorpseTimeoutValue, "delete"); }comment these lines out
the reason you must do this is because after that certain amount of time defined above the player object is deleted so that dead bodies wont accumulate on the ground. and therefore after it is deleted in that time frame you reset function wont work because there is no player object to check if its dead.