Game Development Community

function call from AIPlayer namespace does not work

by Ahsan Muzaheed · in Torque 3D Beginner · 07/17/2011 (9:53 pm) · 1 replies

why any function call from AIPlayer namespace does not work anywhere rather than in
function GameCore::startGame(%game) of gameCore.cs?

to make it work i have to exe my file(containing function call of AIPlayer namespace ) in GameCore::startGame.

why this does not work?
any alternative?

here is my code that i have tried:

//my.cs

function AIPlayer::myspawnOnPath(%name,%path)
{
  %player = new AiPlayer()
   {
      dataBlock = DemoPlayer;
      path = "";
   };
   
   if (!isObject(%path)){  echo("found no path ");return 0;}
   
   %node = %path.getObject(0);
   %player = AIPlayer::spawn(%name, %node.getTransform());
  
return %player;
}

//if (!isObject(%this.player))
 	%player = AIPlayer::myspawnOnPath("Shootme", "MissionGroup/paths/path1");

// if (isObject(%player))
   %player.followPath("MissionGroup/paths/path1", -1);

About the author

Torque 3D enthusiastic since 2010.Have been working in several T3D projects besides of Unreal Engine 4 and Unity 3D. NEED a hand with your project? SHoot me a mail. http://www.garagegames.com/community/forums /viewthread/138437/


#1
07/18/2011 (2:30 am)
You were putting it in the wrong place - the game needs to have already started before you can start calling functions inside it.