2 Korks, on 2 paths...spawns 1 Kork
by Mike Rowley · in Torque Game Engine · 04/01/2006 (11:01 am) · 4 replies
I've been trying to get more than 1 kork, and the second Kork to follow a second path.
I'm using the starter.fps example as a base.
What I've done:
Made a second path and named it "Path2"
copied the spawn function and renamed the bot.
This didn't work. I got one JimBob and no Kork.
I made both into one function by removeing
Got one JimBob, no Kork.
I took the aiPlayer.cs, saved as aiPlayer1.cs and placed Jimbobs code at the bottom.
Got one JimBob, no Kork.
Searched forum for 3 hours
Made a new player dataBlock.
Got 1 JimBob, no Kork
Changed the player in the new datablock to point to a different player.cs (human)
Got 1 JimBob, no Kork.
I'm out of ideas. Everything is compiling fine with no errors, but Kork refuses to appear. If I remove JimBob altogether, Kork appears. I'm lost from here.
So that you know, I have Not made any changes to the stock sdk and am using the demo exe that ships with tge.
Anyhelp on this?
Oh, and the new datablock only changes the name and player.
I'm using the starter.fps example as a base.
What I've done:
Made a second path and named it "Path2"
copied the spawn function and renamed the bot.
function AIManager::spawn(%this)
{
%player0 = AIPlayer::spawnOnPath("Kork","MissionGroup/Paths/Path1");
%player0.followPath("MissionGroup/Paths/Path1",-1);
%player0.mountImage(CrossbowImage,0);
%player0.setInventory(CrossbowAmmo,1000);
return %player0;
}
function AIManager::spawn(%this)
{
%player1 = AIPlayer::spawnOnPath("Jim Bob","MissionGroup/Paths/Path2");
%player1.followPath("MissionGroup/Paths/Path2",-1);
%player1.mountImage(CrossbowImage,0);
%player1.setInventory(CrossbowAmmo,1000);
return %player1;
}This didn't work. I got one JimBob and no Kork.
I made both into one function by removeing
}
function AIManager::spawn(%this)
{Got one JimBob, no Kork.
I took the aiPlayer.cs, saved as aiPlayer1.cs and placed Jimbobs code at the bottom.
Got one JimBob, no Kork.
Searched forum for 3 hours
Made a new player dataBlock.
datablock PlayerData(PlayerGuard)
Got 1 JimBob, no Kork
Changed the player in the new datablock to point to a different player.cs (human)
Got 1 JimBob, no Kork.
I'm out of ideas. Everything is compiling fine with no errors, but Kork refuses to appear. If I remove JimBob altogether, Kork appears. I'm lost from here.
So that you know, I have Not made any changes to the stock sdk and am using the demo exe that ships with tge.
Anyhelp on this?
Oh, and the new datablock only changes the name and player.
#2
I had tried this already, but with 2 different return statements.
Oh, and for anyone else looking for the answer, return %this is the correct syntax. :)
04/01/2006 (12:21 pm)
Thankyou very much.I had tried this already, but with 2 different return statements.
Oh, and for anyone else looking for the answer, return %this is the correct syntax. :)
#3
Try putting some echos in AIPlayer::SpawnOnPath and AIPLayer::Spawn and track down what's not really working. SpawnOnPath checks for a path object. Maybe there's a typo somewhere in the name and it's not being able to find it.
04/02/2006 (6:08 pm)
@Mike,Try putting some echos in AIPlayer::SpawnOnPath and AIPLayer::Spawn and track down what's not really working. SpawnOnPath checks for a path object. Maybe there's a typo somewhere in the name and it's not being able to find it.
#4
The problem was that my return type was wrong. This is the correct way, and works perfectly:
04/03/2006 (12:24 pm)
Thanks Bruno.The problem was that my return type was wrong. This is the correct way, and works perfectly:
function AIManager::spawn(%this)
{
%player0 = AIPlayer::spawnOnPath("Kork","MissionGroup/Paths/Path1");
%player0.followPath("MissionGroup/Paths/Path1",-1);
%player0.mountImage(CrossbowImage,0);
%player0.setInventory(CrossbowAmmo,1000);
%player1 = AIPlayer::spawnOnPath("Jim Bob","MissionGroup/Paths/Path2");
%player1.followPath("MissionGroup/Paths/Path2",-1);
%player1.mountImage(CrossbowImage,0);
%player1.setInventory(CrossbowAmmo,1000);
return %this;
}
Torque Owner Kirby Webber
Try something like this instead:
function AIManager::spawn(%this) { %player0 = AIPlayer::spawnOnPath("Kork","MissionGroup/Paths/Path1"); %player0.followPath("MissionGroup/Paths/Path1",-1); %player0.mountImage(CrossbowImage,0); %player0.setInventory(CrossbowAmmo,1000); %player1 = AIPlayer::spawnOnPath("Jim Bob","MissionGroup/Paths/Path2"); %player1.followPath("MissionGroup/Paths/Path2",-1); %player1.mountImage(CrossbowImage,0); %player1.setInventory(CrossbowAmmo,1000); return %player0; return %player1; }Not so sure about the return statements, but when you declare two functions with the same exact name, you essentially overwrite the original in memory.