Game Development Community

AIPlayer function

by Tasty Green Pees :-, · in Torque Game Engine · 02/20/2006 (1:02 am) · 2 replies

I've created an ai driven player from the beginner's tutorial. It work fine however...

I was wondering where, in the bottom peice of code, the AIPlayer object/function/datablock was called from. Or is this AIPlayer function being created right here?

function AIPlayer::spawn( %name, %spawnPoint )
{
	// Create the A.I. driven bot object...
	%player = new AIPlayer()
	{
		dataBlock = MyBot;
		path = "";
	};

	MissionCleanup.add( %player );
	%player.setShapeName( %name );
	%player.setTransform( %spawnPoint );

	return %player;
}

Thank you

#1
02/20/2006 (3:17 am)
That code *is* the function and it is being created, as you're using the "function" syntax.
You're not very clear.

%player is the object ID which is returned from new AIPlayer(){};.
The datablock is created elsewhere before the function is called.
#2
02/20/2006 (10:38 am)
Yeah that makes sense. I'm kinda a new to this so sometime I need things to be spelled out for me.

The explanation really clarified it, thanks.