Game Development Community

Spawned AIPlayer to follow Path set in Editor in T3D

by chris21 · in Game Mechanics Kit · 03/26/2013 (4:37 am) · 2 replies

Hi everyone,

i know this has been asked a dozen times, but i still don't find the answer.

The case is as follows:

I have a NPC AIPlayer that i spawned using the editors Player Spawn Sphere (e.g. placing a character that is standing at the entrance of a builidng, etc).

When i restart the game, the Character is standing at the right location. So far, so good.

Now i simply want that Character to follow a simple path i also defined using the Editor (e.g. for walking up and down the street).

Now i just can't get that Character follow the path (first i thought one could simply place it below the path node in the editor, but i recognized it's going to be more difficult than that :-) ).

I did set up the player using an AIPlayer.cs file, a NPCPlayerDatablock and the Path.

Now i just do not know how to connect these.

I do have to connect the AIPlayer to the Path, somehow, don't I?

I would be very happy if anyone has a straight forward hint to this.

Many thanks,
C

About the author

Recent Threads


#1
03/26/2013 (7:56 am)
You need to send the function "followPath". Look in scripts/server/aiplayer.cs for the function.

//AIPlayer::followPath(%this,%path,%node)
myAiName.followPath(pathname, -1);
// -1 node means loop

And make sure that it is an Ai and not a player you spawned. ;)

There's also a couple of simple game tutorials which deal with Ai and paths on the T3D guids page under the community section.
www.garagegames.com/products/torque-3d/guides
#2
03/30/2013 (4:35 am)
Thanks a lot for the fast reply!

I finally got my NPC follow that path. It's actually easier than i thought.

I'll put together a short step by step for any beginner who is interested.