Game Development Community

AI spawning problem

by CoderT · in Torque 3D Beginner · 11/04/2012 (6:13 am) · 8 replies

Hi,

I been trying to spawn some ai but so far no luck.

I added a script to scripts/client. A script I execute in the init.cs script.

This is the spawning function, everything is at default where the rest of the project is concerned.

function spawnBot()
{
%bot = AIPlayer::spawn("aiUnit1", "MissionGroup/aispawn1");
return %bot;
}

I placed a SpawnSphere in the editor and named is "aispawn1". Which is where it should spawn. Except nothing happens.
I call the spawnBot function through the console/script btw.

What am I doing wrong?


Thanks.

#1
11/04/2012 (8:34 am)
Try looking at scripts/server/aiPlayer.cs
#2
11/04/2012 (9:28 am)
Yes that is where the function is calls is location. What about it?
#3
11/04/2012 (9:36 am)
Quote:I added a script to scripts/client

try moving your script to scripts/server

EDIT: also add your script file to scripts/server/scriptExec.cs
#4
11/04/2012 (10:45 am)
Try working through The RTS Prototype, it spawns AI in a few different ways.
#5
11/04/2012 (5:54 pm)
The spawning example from the rts works but than I loose all the other options I had.

So how do I get my example working?

And it works both when in scripts/client or scripts/server btw.
#6
11/05/2012 (11:49 am)
Create A Custom AIPlayer

This is a pretty good tutorial. It worked fine for me. I ended up leaving out the fullauto and semiauto code.
#7
11/05/2012 (12:14 pm)
Do you have a valid datablock for aiUnit1?

Also, AIPlayer::Spawn() is expecting a transform instead of a name for a marker.

#8
11/07/2012 (2:37 pm)
Yes, it works in either scripts/client or scripts/server - until you try to run it in multiplayer. Then only the client who hosted will see the AI, or perhaps each client will see their own copy of the AI, or some other really fun hijinks will ensue. For this reason, all AI code is best kept in scripts/server.

Additionally, this ensures that the server is controlling spawning and "thinking."