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.
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.
About the author
#2
11/04/2012 (9:28 am)
Yes that is where the function is calls is location. What about it?
#3
try moving your script to scripts/server
EDIT: also add your script file to scripts/server/scriptExec.cs
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
So how do I get my example working?
And it works both when in scripts/client or scripts/server btw.
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
This is a pretty good tutorial. It worked fine for me. I ended up leaving out the fullauto and semiauto code.
11/05/2012 (11:49 am)
Create A Custom AIPlayerThis is a pretty good tutorial. It worked fine for me. I ended up leaving out the fullauto and semiauto code.
#7
Also, AIPlayer::Spawn() is expecting a transform instead of a name for a marker.
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
Additionally, this ensures that the server is controlling spawning and "thinking."
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."
Associate Britt Scott