How to get a AIBot to follow a path ?
by Rapid Fire · in Game Mechanics Kit · 11/30/2009 (12:10 pm) · 4 replies
I've been trying to get a AIBot to patrol a path. I added a path with 5 markers, and on the bots OnSpawn event, i added this code SpaceOrcBot01.followPath(Path05, $Path::PATROL, 1, Path05Marker_1, Path05Marker_5); .
Am i doing something wrong, or not doing it right, he just sits there after he spawns. Any help would be appreciated.
Thanks.
Am i doing something wrong, or not doing it right, he just sits there after he spawns. Any help would be appreciated.
Thanks.
#2
Where would i put this code, same place as i put the previous code, in my mission file ?
Sorry i'm a little new to scripting.
Best regards.
12/01/2009 (10:02 am)
Thanks Yuri, I will give it a try.Where would i put this code, same place as i put the previous code, in my mission file ?
Sorry i'm a little new to scripting.
Best regards.
#3
EDIT - I got it to work :) . I added this to on spawn:
onSpawn = " %this.allowTacticalMovement(false); %this.followPath(OrcPath0, $Path::PATROL, 1, -1, -1);";
He now patrols along a path. When i use TO_TARGET, the ai acts like a turret, perfect for my needs.
Thanks,
Best Regards.
12/01/2009 (1:04 pm)
Ok, i added that code into the mission file, now the bot stands there and faces the player no matter where he goes. Is there anything i should do to get him to walk along the path. Its close :)EDIT - I got it to work :) . I added this to on spawn:
onSpawn = " %this.allowTacticalMovement(false); %this.followPath(OrcPath0, $Path::PATROL, 1, -1, -1);";
He now patrols along a path. When i use TO_TARGET, the ai acts like a turret, perfect for my needs.
Thanks,
Best Regards.
#4
I found the probable source of your issue.
When Path description in *.MIS file is after the aiBot then OnSpawn event won't find the right Path by its name.
Try to change AiBot onSpawn to this:
onSpawn = "%this.allowTacticalMovement(false); %this.schedule(1, "followPath", PatrolPath01, $Path::PATROL);";
06/30/2010 (7:50 am)
Hi,I found the probable source of your issue.
When Path description in *.MIS file is after the aiBot then OnSpawn event won't find the right Path by its name.
Try to change AiBot onSpawn to this:
onSpawn = "%this.allowTacticalMovement(false); %this.schedule(1, "followPath", PatrolPath01, $Path::PATROL);";
Torque Owner Yuri Dobronravin
Logicking
Check out Orcs Rule demo game, there is code for Bot path following.
Consider this code from server\logickingMechanics\packages.cs
onAlert = " %this.allowTacticalMovement(false); %this.followPath(OrcPath0 @ getRandom(2), $Path::TO_TARGET, 1, -1, -1);";
Try to change your code from PATROL to TO_TARGET mode and make nodes -1, -1 like in the example above. Will it work?