AIplayer, SetPose, UpdateMove and MoveManager?
by Steve Acaster · in Torque 3D Professional · 05/21/2010 (4:28 pm) · 6 replies
So, I was hoping rather naively that making a simple setPose() consoleMethod in Player.cpp, would allow me to use it on AIplayers in a %obj.setpose(#0-2); type of manner, basically in the same way my getPose() consoleMethod returns #0-3 (nice and easy that one).
However, trying the easy way, it always returned 0, no matter what the # setPose received.
I thought that this might be because of the $mvTriggerCount which the player uses to activate this sort of thing via input --- which gets updated every tick. So after I - and when I say I - I of course mean someone else who knows how to code properly but is currently lying broken over the jagged pinnacles of their keyboard - so I'm posting this, thought that firing the function off from the base of aiGetMove where it deals with trigger replication might be best,
then updating it through a trace of UpdateMove in player to MoveManager - so that it get called/tested on every tick - and then gets checking in player UpdateMove to see if it's an aiplayer before finally being passed to aiGetMove and an AIplayer setPose function.
movemanager-> updatemove->||||| setpose-> AI
sorry if that was incomprehensible
It does get passed as far back as the UpdateMove (AI.setpose(1)), but doesn't appear to getting through to the controlling setPose function (getPose(0)).
So, baffled, I was wondering if anyone had any thoughts, tips, or methods of their own to get an AIplayer to sitdown and have his bounding box follow him?
ConsoleMethod( Player, getPose, S32, 2, 2, "(Pose)")
{
return object->getPose();
}
//nice easy one thatHowever, trying the easy way, it always returned 0, no matter what the # setPose received.
I thought that this might be because of the $mvTriggerCount which the player uses to activate this sort of thing via input --- which gets updated every tick. So after I - and when I say I - I of course mean someone else who knows how to code properly but is currently lying broken over the jagged pinnacles of their keyboard - so I'm posting this, thought that firing the function off from the base of aiGetMove where it deals with trigger replication might be best,
// Replicate the trigger state into the move so that
// triggers can be controlled from scripts.
for( int i = 0; i < MaxTriggerKeys; i++ )
movePtr->trigger[i] = getImageTriggerState(i);
movePtr->AIPose = mAIPose;
return true;then updating it through a trace of UpdateMove in player to MoveManager - so that it get called/tested on every tick - and then gets checking in player UpdateMove to see if it's an aiplayer before finally being passed to aiGetMove and an AIplayer setPose function.
movemanager-> updatemove->||||| setpose-> AI
sorry if that was incomprehensible
It does get passed as far back as the UpdateMove (AI.setpose(1)), but doesn't appear to getting through to the controlling setPose function (getPose(0)).
So, baffled, I was wondering if anyone had any thoughts, tips, or methods of their own to get an AIplayer to sitdown and have his bounding box follow him?
About the author
One Bloke ... In His Bedroom ... Making Indie Games ...
#2
05/24/2010 (5:41 am)
Simple: make the AIPlayer press the "buttons" which activate the poses. This is the code that switches poses in Player::updateMove()if ( mSwimming ) desiredPose = SwimPose; else if ( runSurface && move->trigger[3] && canCrouch() ) desiredPose = CrouchPose; else if ( runSurface && move->trigger[4] && canProne() ) desiredPose = PronePose; else if ( canStand() ) desiredPose = StandPose; setPose( desiredPose );So, setting triggers 3 and 4 in AiPlayer::getAIMove() will switch to the poses you want.
#3
So I take it that the %this.trigger which I have since found in Aiplayer.cs refers to the setting of the trigger in Aiplayer.cpp ... which is the one handling the image/weapon trigger ...
05/24/2010 (7:33 am)
Ahhh... so I was approaching it from the wrong side completely by trying to circumnavigate the whole trigger thing (because the Ai don't have input) ... thought I might've been ...//AIplayer.cs
function AIPlayer::singleShot(%this)
{
// The shooting delay is used to pulse the trigger
%this.setImageTrigger(0,true);
%this.setImageTrigger(0,false);
%this.trigger = %this.schedule(%this.shootingDelay,singleShot);
}
//....
function AIPlayer::fire(%this,%bool)
{
if (%bool) {
cancel(%this.trigger);
%this.singleShot();
}
else
cancel(%this.trigger);
%this.nextTask();
}So I take it that the %this.trigger which I have since found in Aiplayer.cs refers to the setting of the trigger in Aiplayer.cpp ... which is the one handling the image/weapon trigger ...
//AiPlayer.cpp
bool AIPlayer::getAIMove(Move *movePtr)
//.....
// Replicate the trigger state into the move so that
// triggers can be controlled from scripts.
for( int i = 0; i < MaxTriggerKeys; i++ )
movePtr->trigger[i] = getImageTriggerState(i);
#6
Yep that seems to work fine and I can see where I was going wrong.
Only issue is that my Ai occaisionally need a bump (literally) to update the animation (bounding box updates instantly, no probs).
As a work around I've come up with calling a transform on itself when it gets the setpose as a sort of "jump start" for the transition.
But save for that -- all is good. :)
You might fancy submiting this as a resource.
[EDIT]
Actually I'm wondering if my animation delay/non-start_without_a_nudge is down to my custom skeleton as I see bip# is hardcoded to resolve spinal movements ...
But yeah, crouches and stands fine on stock Gideon model.
05/29/2010 (8:04 am)
#1Yep that seems to work fine and I can see where I was going wrong.
Only issue is that my Ai occaisionally need a bump (literally) to update the animation (bounding box updates instantly, no probs).
As a work around I've come up with calling a transform on itself when it gets the setpose as a sort of "jump start" for the transition.
%this.setpose(%pose); %this.setTransform(%this.getTransform());
But save for that -- all is good. :)
You might fancy submiting this as a resource.
[EDIT]
Actually I'm wondering if my animation delay/non-start_without_a_nudge is down to my custom skeleton as I see bip# is hardcoded to resolve spinal movements ...
But yeah, crouches and stands fine on stock Gideon model.
Torque Owner Ivan Mandzhukov
Liman3D
No input (AIs) is equal to mPose = 0