T3D 1.1 Preview - setMoveDestination doesn't move AI - RESOLVED (THREED-1717)
by Steve Acaster · in Torque 3D Professional · 04/18/2011 (11:53 am) · 5 replies
T3D 1.1 Preview
win7 32bit
target:
script -> Ai functions
Issue:
When spawning an AI (not on a path) and calling "setMoveDestination" function, the Ai can only face towards the target and is incapable of moving.
Repeat:
1. Add a new spawn function in scripts/server/aiplayer.cs for easy spawning.
2. In game add 2 markers, spawnspheres, waypoints. Call them "w1" and "w2".
3. In console spawn Ai.
4. when "bob" has arrived, using the console again, set him to move to the second marker
5. Watch "bob" turn to face in the correct direction ... but "bob" cannot move ...
Suggest:
Fix it! "bob" should run over to his destination and then stop.
win7 32bit
target:
script -> Ai functions
Issue:
When spawning an AI (not on a path) and calling "setMoveDestination" function, the Ai can only face towards the target and is incapable of moving.
Repeat:
1. Add a new spawn function in scripts/server/aiplayer.cs for easy spawning.
function AIPlayer::customSpawn(%name, %aitype, %spawnPoint)
{
if(isObject(%spawnPoint))
{
%player = new AIPlayer(%name)
{
dataBlock = %aitype;
};
MissionCleanup.add(%player);
%player.setShapeName(%name);
%player.setTransform(%spawnPoint.gettransform());
return %player;
}
}2. In game add 2 markers, spawnspheres, waypoints. Call them "w1" and "w2".
3. In console spawn Ai.
aiplayer::customSpawn(bob, demoplayer, w1);
4. when "bob" has arrived, using the console again, set him to move to the second marker
bob.setMoveDestination(w2.gettransform());
5. Watch "bob" turn to face in the correct direction ... but "bob" cannot move ...
Suggest:
Fix it! "bob" should run over to his destination and then stop.
About the author
One Bloke ... In His Bedroom ... Making Indie Games ...
#2
04/18/2011 (1:49 pm)
Yeah, both of those solutions get the Ai up and moving. I'd also agree that the first suggestion of letting the scripts handle what to do when a bot is Stuck is the best.
#3
04/21/2011 (3:55 pm)
Logged as THREED-1717.
#4
05/26/2011 (11:54 am)
Fixed in 1.1 Final.
#5
05/26/2011 (1:14 pm)
I did some further testing on this issue and found that if you moved the AI between two points in a water block and then move him outside of the block of water he continues to play the swim animation. Logged as THREED-1938.
Torque 3D Owner Twisted Jenius
Build: T3D Pro 1.1 Preview
Platform: Windows 7 SP 1, 64 bit
Target: Visual Studio
Issues:
If an AI agent is stopped from moving for any reason (including by use of an explicit %obj.stop()) for even a split second, it will not be able to move again (unless a drastic measure is taken, such as shooting it with a rocket at the same time it's trying to move).
If the bot ever stops moving for any length of time, for any reason, it is now considered to be stuck and its "mMoveState" is set to "ModeStop". But after the bot comes to a full and complete stop, it can't start up again and move a sufficient distance before "getAIMove()" is next called. So it is then flagged as being stuck once more the next cycle and completely stops moving yet again; repeating this indefinitely. The only way it can begin moving after that is if it is already moving as it is trying to move (already moving by being hit with a rocket or whatnot).
Steps to Repeat:
1. Load a mission with a stock AIPlayer running around a path.
2. Completely stop the bot from moving for a split second. This can be done by blocking its path with an object (including the player).
3. Note how the bot will not start moving on its own ever again; even if you set a new move destination for it.
Suggested Fix:
Change the code around line 315 of aiPlayer.cpp to be:
//mMoveState = ModeStop; throwCallback("onMoveStuck");Then just let any AI behavioral scripts use the "onMoveStuck" callback to decide what the bot should do after that.
As a temporary workaround in script, you can add something similar to the following immediately after the bot is spawned.