Game Development Community

Change the shapefile

by CodingChris · in Torque Game Engine · 08/12/2007 (12:10 am) · 4 replies

Hi,
how to change the shapefile of a defaultcar on the fly?
Hope for help.

#1
08/12/2007 (1:21 am)
Inherent other players from your main player datablock and use the "setDatablock" method.

Example:
  • In server/scripts/player.cs you will have a default player datablock:
  • datablock PlayerData(PlayerBody)
    {
       renderFirstPerson = false;
       emap = true;
       
       className = Armor;
       shapeFile = "~/data/shapes/player/player.dts";
    };
  • Inherent other player shapes from this datablock. You need only add in properties that you want to differ from the defaults:
  • datablock PlayerData(Soldier : PlayerBody)
    {
       shapeFile = "~/data/shapes/soldier/soldier.dts";
    };
    
    datablock PlayerData(Smurf : PlayerBody)
    {
       shapeFile = "~/data/shapes/smurf/smurf.dts";
    };
  • Now grab the player ID of your player, if you don't know how to do this just hit F11 to raise the editor and take note of the four digit number assigned to your main player controlled object.
  • Now type this into the console, where %player is your player's server ID:
  • %player.setDatablock(Soldier);
  • Voila. Your player will change to whatever shape you specified within the Soldier datablock.
#2
08/12/2007 (1:24 am)
Can I change the defaultcar datablock with
%player.setDatablock(Soldier);
too?
#3
08/12/2007 (1:30 am)
Sure, it's the same theory just different types of datablocks (WheeledVehicle VS Player).
#4
08/12/2007 (1:34 am)
Thanks