Game Development Community

Changing player type dynamically

by Tom · in Torque Game Engine · 11/03/2008 (6:16 pm) · 1 replies

Hello everyone,

with school, and exams, and work, its hard to get anything done; but recently i have had an idea

and trying to get my idea realized in tests proved so far impossible.

i searched the forums trough old posts and found some interesting posts that were helpful for some aspects, but not all.

anyway, here is what i am trying to do

client is player character, behaves like kork,

then player presses a key, data block is switched to a plane,

now behaves like a flying vehicle

i have the datablock switching done, but my airplane doesnt fly,

im wondering if anyone knows how to set the player type (new player, new flyingvehicle, new wheeledVehicle, etc) dynamically ingame.

i got the datablock stuff working, just not the player type change, has anyone ever tryed this? if not ill post my work once i get it to work :)

but yeah, i would appreciate any useful input

thanks everyone :)

*btw, im trying to keep engine mods to a minimum, so if its possible to do inscript, that would be amazing

#1
11/03/2008 (9:41 pm)
You probably just missed swapping control over to the new vehicle. Something like this should get you going:
function serverCmdChangeToFlyer(%client)
{
     %vehicle = new FlyingVehicle()
     {
        dataBlock = OrcBird;
     };
     MissionCleanup.add(%vehicle);
     %vehicle.setTransform(%client.player.getEyeTransform());
     // give the client control of the vehicle
     %client.player = %vehicle;
     %client.setControlObject(%vehicle);
}

//Bind  "Cntl F" to spawn a vehicle and take control of it
moveMap.bindCmd(keyboard, "ctrl f", "commandToServer(\'ChangeToFlyer\');", "");

You'll still need to handle removal of the old player body and linking up the health and energy bars, but it's all possible in script.