Game Development Community

AI player on path keeps on rotating own axis

by Nils Eikelenboom · in Torque 3D Professional · 03/06/2013 (7:13 am) · 19 replies

When I spawn a AI player on a path with this specific character (Wild Boar) it doesn't follow the path but keeps on rotating on its own axis (see video) The animations are embeded in the (Open)Collada file (export from 3ds max) and drawn from 'Ambient'. Other items, such as the Death animation when I shoot it, seem to be working. Other characters (human in either DTS or DAE) are following the path just fine. The datablock is copied from 'DefaultPlayerData' into a new one (in player.cs)


www.youtube.com/watch?v=pJzTfPSIHPw

i-dropper.net/torque/AiPlayer-Animal.jpg

i-dropper.net/torque/AiPlayer-Animal-Nodes.jpg
In the images you see that the bone structure is slightly different from Soldier or Gidion (an extra node between calf and foot for example). Tried leaving the 'Footsteps' node out or moving it to another position.
Tried using different sizes of collision boxes. Dragging the player over the path makes it stop moving/animating.

Anybody a clue what I've done wrong here?

The .cs file:

singleton TSShapeConstructor(WildBoarDAE)
{
baseShape = "./WildBoar.DAE";
loadLights = "0";
unit = "1.0";
upAxis = "DEFAULT";
lodType = "TrailingNumber";
ignoreNodeScale = "0";
adjustCenter = "0";
adjustFloor = "0";
forceUpdateMaterials = "0";
};

function WildBoarDAE::onLoad(%this)
{
%this.addSequence("ambient", "root", "0", "1", "1", "0");
%this.setSequenceCyclic("root", "0");
%this.addSequence("ambient", "Run", "0", "19", "1", "0");
%this.addSequence("ambient", "Death1", "119", "139", "1", "0");
%this.setSequenceCyclic("Death1", "0");
%this.addSequence("ambient", "Jump", "40", "57", "1", "0");
%this.setSequenceCyclic("Jump", "0");
%this.addSequence("ambient", "Land", "79", "98", "1", "0");
%this.setSequenceCyclic("Land", "0");
%this.addSequence("ambient", "Sitting", "119", "139", "1", "0");
%this.setSequenceCyclic("sitting", "0");
%this.addSequence("ambient", "Fire", "40", "57", "1", "0");
%this.addSequence("ambient", "Reload", "19", "20", "1", "0");
%this.setSequenceCyclic("Reload", "0");
%this.addSequence("Run", "Side", "0", "19", "1", "0");
%this.addSequence("Run", "Side_Right", "0", "19", "1", "0");
%this.addSequence("Run", "Swim_Forward", "0", "19", "1", "0");
%this.addSequence("Run", "Crouch_Backward", "0", "19", "1", "0");
%this.addSequence("Run", "Crouch_Foward", "0", "19", "1", "0");
%this.addSequence("Run", "Crouch_Side", "0", "19", "1", "0");
%this.addSequence("Run", "Crouch_Root", "0", "19", "1", "0");
%this.addSequence("Run", "Sprint_Backward", "0", "19", "1", "0");
%this.addSequence("Run", "Sprint_Foward", "0", "19", "1", "0");
%this.addSequence("Run", "Sprint_Side", "0", "19", "1", "0");
%this.addSequence("Run", "Sprint_Root", "0", "19", "1", "0");
%this.addSequence("Run", "Swim_Backward", "0", "19", "1", "0");
%this.addSequence("Run", "Swim_Root", "0", "19", "1", "0");
%this.addSequence("Run", "Swim_Left", "0", "19", "1", "0");
%this.addSequence("Run", "Swim_Right", "0", "19", "1", "0");
%this.addSequence("Run", "Fall", "0", "19", "1", "0");
%this.addSequence("Run", "Back", "0", "19", "1", "0");
%this.addSequence("ambient", "Look", "0", "12", "1", "0");
%this.addSequence("ambient", "Head", "0", "12", "1", "0");
%this.setSequenceCyclic("Head", "0");
%this.addNode("Cam", "Eye", "0 0 0 0 0 1 0", "0");
%this.addSequence("ambient", "Death2", "119", "139", "1", "0");
%this.setSequenceCyclic("Death2", "0");
}

#1
03/06/2013 (7:31 am)
Doesn't seem to be an animation problem but an AI problem. Like if it tried to reach a nodes position but never hit the position accurately enough to be accepted by the AI.
#2
03/06/2013 (7:48 am)
@Lucas. Thanks for reply! Other characters like soldier are following the path just fine. It seems the issue is with this one. It never leaves path node 0. The video is a but jerky; but the character is actually rotating very fast.
#3
03/06/2013 (8:00 am)
Aren't bounding boxes global and not local? Not having an xy square ...

[edit] disregard, I need more tea ...

Check that it's datablock can actually move, speed, friction values etc
#4
03/06/2013 (8:28 am)
did u try with higher value of "mMoveTolerance" ?

i had that problem with my ai when i set smaller value for mMoveTolerance.
and perform a "setMoveDestination " command.

nice level.
where did get that mode?
arteria3d?
#5
03/06/2013 (8:35 am)
Is the bounding box under the ground, could it be stuck?
#6
03/06/2013 (9:44 am)
Thanks for the replies!

@Steve; Bounding box is in the datablock. Tried different sizes. Also tried a different shape (actor) and that worked just fine. Will try some different values then.

@Ahsan; Tried different move tolerances, I'll try some more then. Most what you see is made in house but this model is one of the few exceptions. Original bought from Turbosquid (especially for the 4 legs animation) and reworked a bit.

@Inflight; The white edges of the bounding box remain above ground.
#7
03/07/2013 (6:26 am)
The bounding box in the video doesn't match the one in the picture, somethings wrong there.
#8
03/08/2013 (12:04 am)
@Winter Leaf; The bounding box is set in the datablock in player.cs (default in T3D 1.2) and overrules the one in the shape. I tried different sizes including a matching one, but that didn't help any. The one in the video was the last one I tried.



Tried different mMoveTolerance and MoveStuckTolerance values but all I saw was the ai player stopping faster, not resolving the rotating and make it follow a path.

I've installed the AISK now; maybe this will be any good...

#9
03/08/2013 (8:21 am)
Perhaps try setting it to face the next node manually in the node reached callback? This sort of spinning can occur when an AI unit is very near or at its destination coordinate when using setMoveDestination(), so maybe it's being told to face local 0,0,0 somehow.
#10
03/08/2013 (9:15 am)
It looks like it is moving the bounding box to the location, but it is looking at a different point altogether. So the error never reduces to within tolerance.

To find out for sure I would go into AIPlayer and print current position, destination position, and the error value. This should give you better idea of what might be going on.
#11
03/09/2013 (1:05 am)
I found that repositioning the eye node to the back and high enough above the shape, the Ai player can move without rotating/shaking.

The current structure seems not to be suitable for 4 legged players. The rotation point is at the feet of the bone structure, in this case the 'back feet'. When setting the bounding box to meet up the shape it can't follow the ground correctly because the rotation point is also at the 'back feet'. To solve this I guess I'll need to use 'Prone/Swimming' instead of 'Standing' which involves a different bounding box, the eye node could be then at the right position. That will also solve the problem of incorrect hitboxes.

Also do I need to add AI behaviour to ram into the player for damage as the Boars can't go running around shooting at the player ;-)

Thanks for the help!
#12
03/09/2013 (5:34 am)
Add a function for onCollision() to check that the object hit is a player, and that the player has a client and apply some damage.
#13
03/09/2013 (6:32 am)
Well, why can't the boars shoot at players? That hardly sounds fair, since the players can shoot the boars....
#14
03/10/2013 (10:25 am)
@Steve; that would be too easy; though fun for short time of course!

@Richard; when the Boar rams its tusks into the lower parts of the player it becomes really messy. It's not uncommon that victims are torn open after they found out that the calibre they used to shoot the boar wasn't heavy enough and really pissed it off ;-P

Ai player is moving now (and can attack and all) but somehow unable to detect whether it reached the node of a path or not. Tried moving the eye node to various positions without much good coming out of it.
#15
03/10/2013 (11:31 am)
@Nils,
What does the eye node have to do with this? Is this the point that is trying to be brought into the path position?
#16
03/10/2013 (9:11 pm)
@Frank, I think so. In AIPlayer::getAIMove (aiPalyer.cpp) it's using getEyeTransform(&eye); to get the current position.

I started out with the eye node at the position of the boar's eyes. If I move the node backwards and higher; more to the position where the human eye would be the bot stops to rotate wildly around the path nodes but doesn't move any further. Perhaps it has something to do with the ray not casted correctly with this model?
#17
03/11/2013 (5:23 am)
Would it hurt to move the model center to the front legs? I think you can do this in the shape editor in T3D to test it out. I am not 100% sure though.
#18
03/11/2013 (5:56 am)
You should keep in mind measurement in your game, because destination logic is based on a tolerance and at some point this tolerance could be passed a bit, resulting in a strange rotation around a destination point.
#19
03/11/2013 (10:20 pm)
@Frank; Good idea to do it in the editor (was already moving the shape in 3ds max but had some issues because working in the 'Motion Flow Mode'), but it only seem to help a bit; the rotation speed is reduced. Good thing is that the bounding box from the datablock is now fitting much better. Though I beleieve I'll still need to try to make the player move with the prone/swim state; this boundingbox is ment for horizontal shaped players, I think.

@Ivan; I use the default unit size. T3D Stock shapes have a 'normal' size in the levels as all the other assets. Or do you mean something else? I already have 'in house made' players following paths without any issues; but these are built simular to 'Gidion' (TP) and 'Soldier' (FP)