Game Development Community

%client.player doesn't work

by Grant McNeil · in Torque Game Engine · 06/12/2002 (12:09 pm) · 1 replies

what file contains the functions and information for
%client.player? I'm having alot of problems with this and whenever i try to do somthing with %client.player it doesn't work (eg. %client.player.getTransform();).

Could someone please tell me what im doing wrong??

Grant McNeil

#1
06/12/2002 (12:30 pm)
Well in scripts %client is the client network object and %player is the game object.

The %player object is created like so:
// Remember that %this is like a pointer, but unlike 
//C++ we have to have %this explicit in the function 
//param. Therefore in this instance %this and %client 
//are the same
function GameConnection::createPlayer(%this, %spawnPoint)
{
   // some stuff here

   // Create the player object
   %player = new Player()
   {
      dataBlock = LightMaleHumanArmor;
      // Point the %player object to the %client object
      //   remember %this is the %client object
      client = %this;
   };
   MissionCleanup.add(%player);

   // some stuff here

   // Now point the %client object to the %player object
   //   remember %this is the %client object
   %this.player = %player;

   // some stuff here
}

So getting back to your original question, for the function that you are in, make sure that you have either a %client or a %player object accessable. %client isn't global nor is %player but both can be accessed as long as you have access to one or the other.