Game Development Community

Make an AIPlayer sprint?

by Matthew Genge · in Torque 3D Professional · 03/04/2012 (2:38 pm) · 13 replies

Dear All,

I am trying to get AIPlayers to work. I'm using the zombie pack models which have three sets of idle animations, two runs, and two sprints. However, the engine seems to only use one animation for idle (the "root" animation) and one animation (the "run" animation) for all movement with setMoveDestination. I'd like my zombie to use a sprint animation when moving at a certain speed, and to change the idle animations.

I've tried using setActionThread(sequencename) but this runs into the gliding bug where the move animation is not played, and the idle animation continues during motion with setMoveDestination. Bizarrely I tried to use this behaviour by setting the sprint animation prior to setMoveDestination and instead it dutifully "unbugs" and plays the run animation.

My question...how to get an AIPlayer to sprint? The AIPlayers seem to be moving at maxForwardVelocity rather than maxForwardSprintVelocity, and setting setMoveSpeed() to a value above 1.0 seems to have no effect. Can the engine be coaxed into playing the sprint animation?

It would even be better if I could turn off engine control of animations all together, then use the much better playThread() method where I can control the speed of the animation. I guess it isn't possible without modifying the engine to stop it ruining the animations? Where can I shoot the engine in the head so it will stop messing everything up?

Many thanks,
Matt

#1
03/04/2012 (3:20 pm)
From looking at the source you should be able to set the image trigger on the AI before you set the movement destination.

%youraiobject.setImageTrigger(5, true); //Sprint trigger

and then call this when you reach the destination.
%youraiobject.setImageTrigger(5, false); //Sprint trigger
#2
03/04/2012 (4:21 pm)
i was able to make those zombies(from zombie pack models) to run.
not clear,what different u are trying to do!!!!!
here is a video:

i have not bought zombie pack.
it is from someone's work,that is i am doing now in a contract.
#3
03/05/2012 (9:15 am)
Just toggle the relevant mvTrigger[x].

setMoveSpeed() works as a scalar (0-1) for movement speed, with 1 being top speed or 100%.
#4
03/05/2012 (10:48 am)
@Matt

I remember them sprinting, just by editing their datablock to enable starting energy amount ... and then setting up sprint to use some energy and require a minimum amount before sprinting.

If I recall, this caused them to sprint everywhere ... because I didn't setup a method to deduct the energy every tick or so, while sprinting.

edit: The engine itself chooses which movement animation to play ... you can define walk, run, sprint sure ... but the speed if the character somehow dictates which animation to use.

#5
03/06/2012 (3:56 pm)
Thanks for the suggestions but I still am looking for my silver bullet to shoot the engine in the head.

%obj.setImageTrigger(5,true);

This appears not to do anything, the documentation says the first parameter is an image slot, so I guess this appies to mounted images.

mvTrigger[x]

Michael thanks for the suggestion, but I can't see any documentation on setting mvTrigger[x]. How can you do this in script? I can see globals such as $mvTriggerCount but these seem to apply to player motion? I am unclear by what you mean.

Jeff. I had great hope this would work...it makes so much sense...but alas no. I've set the energyLevel on spawning to the maximum and ensured the minSprintEnergy is set lower than this level...but the zombies still perform their run animation (rather than the sprint animation). I've checked that the zombie has sufficient energy to sprint...but they appear to be very lazy.

Any suggestions or clarifications would be welcome.


#6
03/06/2012 (8:39 pm)
I did a resource sometime ago on modifying Ai stance behaviour via the triggers to get them to crouch and prone - and I'd expect that the player's stock "sprint" counts as a stance and thus can be expanded upon. Check through my resources list.
#7
03/06/2012 (10:13 pm)
@Matthew -- perhaps a combination of "all the above" will work. As Steve suggested, "sprint" is actually one of the "poses" in t3d 1.2

In fact, its like this; (straight from the code source)
{ Player::StandPose,    "Stand",    "Standard movement pose.\n" },
   { Player::SprintPose,   "Sprint",   "Sprinting pose.\n" },
   { Player::CrouchPose,   "Crouch",   "Crouch pose.\n" },
   { Player::PronePose,    "Prone",    "Prone pose.\n" },
   { Player::SwimPose,     "Swim",     "Swimming pose.\n" },

So, in theory ... you start with the "make AI use poses" resource and extend it to account for sprint as a pose.

then, just tell the zombies to change to sprint pose ... and sprint around ... maybe then it will start using the energy values and possibly "un-sprint" when energy gets used up.

but you might need to also use the imageTriggers -- although I don't see why its necessary so far.
#8
03/07/2012 (12:32 am)
@Matthew -- try this update to the poses stuff from Steve. It seems to set the poses correctly, including Sprint.

www.garagegames.com/community/resources/view/21570

Then, set your datablock energy stuff ... and enable the sprint mode with;

%ID.doSprint();
echo(%ID.getPose() );
#9
03/07/2012 (10:45 am)
That's the ticket Jeff. I'd actually forgotten I'd done something very much like Steve's Resource (and now yours) in order to make jetting, sprinting, and toggleable norm/alt fire scriptable for the AI.
#10
03/07/2012 (10:56 am)
Jetting, oh yeah, I'd almost forgotten about that ...
#11
03/07/2012 (4:05 pm)
I've been putting off the day when I start modifying the engine. Was hoping to do it just in script. At least copying and pasting isn't the most taxing intro to C++. I just know I will break the engine.

Anyway, thanks for the info.

#12
03/07/2012 (6:00 pm)
@Matthew - maybe this other resource, is what you needed all along ...
www.garagegames.com/community/resources/view/21353

It shows how to rename the existing animations ... so you can choose which root, run or sprint animation is used for each model.

no need to hack sprint into working or such.
#13
03/07/2012 (8:29 pm)
Quote:
@Matthew - maybe this other resource, is what you needed all along ...
www.garagegames.com/community/resources/view/21353
It shows how to rename the existing animations

that is what i have done.no extra coding only the renaming


can anyone please tell me what is the benefit of using mvTrigger[x]or setImageTrigger().
instead of renaming sequence to "run" ?