Game Development Community

AI Animations only plays when losing window focus (Kinda fixed?)

by Kevin Mitchell · in Torque 3D Professional · 01/08/2012 (12:14 pm) · 35 replies

I'm making a Melee and Magic system but I'm finding that making the AI perform actions is not working unless I lose screen focus. The moment i click inside the game window they return to root animation. Is this a new issue?

I'm currently looking into the setActionThread function to see what is different about the flow when the window is in focus and when not in focus.

Any tips?

Thanks
Kevin

About the author

Riding Solo since 2005. Current Project: Fated World 2005-Present "... because Torque3D is not just for Tribes style First Person Shooters - but anything which you have the will to create" ~ Steve Acaster

Page«First 1 2 Next»
#21
01/09/2012 (6:46 pm)
The signature of the U32 call has a fifth parameter that has no default value so I expected that it would not be called since you aren't providing the extra value. Obviously I am mistaken - happens, but that's why I figured polymorphism wouldn't save the day on that one. Technically, the call you made doesn't match either signature so I would have expected it to throw a fit at compile time. I didn't try it though.
#22
01/09/2012 (7:21 pm)
only action and forward are required in the function call all others are optional to the function call and are auto set if the paramater count is not a match.

virtual void setActionThread(U32 action,bool forward,bool hold = false,bool wait = false,bool fsp = false, bool forceSet = false);



bool hold = false
bool wait = false
bool fsp = false
bool forceSet = false

so i can call:

setActionThread(RPGPlayerData::LandAnim, true);


and the function still holds true to the call is just the missing parameters that are defaulted to false if not sent into the function call.
#23
01/09/2012 (10:24 pm)
Ooops - that's what I get for not paying attention.
#24
01/09/2012 (11:48 pm)
I have seen a 'similar' behavior, but not limited to AI[?]...

I've seen my player avatar stop running certain animations when I leave focus of the 'game' window[and monitor] and move to a second monitor I have setup.

They are different resolutions, one at 1024 and the 'game' monitor/resolution is at 1600+.

I would watch my avatar instantly take up a 'different' animation as soon as I brought my 'browsing' monitor into focus{I think I started 'running' in place]. As soon as I switched back, things returned to 'normal'/what was running with monitor in focus.

#25
01/10/2012 (4:14 am)
Yes, that sounds very similar, I have not seen affects on the player yet but maybe because he's in the root and standard pose.

I wonder if its something deeper than just animations not playing correctly because of ghost handling.

#26
01/10/2012 (6:00 am)
Ok, in Player::processTick() there is a gate condition dependent on a call to isServerObject() that is used a criteria for handling AI processing. This function is a public member of NetObject and is intended only for single-player use - it's documented as being invalid (probably random) for multiplayer use. It seems odd to use this because of that fact, but there it is.

Might be something to check out, and it might be part of why isGhost is unreliable as well. I'll keep digging, but today looks like it's going to be busy.
#27
01/10/2012 (8:02 am)
I'll start there. Hopefully I'll find something. Might be at work most of the day to day as well as we have 2 big release going out today.


"The life of a programmer."
#28
01/11/2012 (1:38 am)
is serverObject looks fine.

I thought it was pickActionAnimation over writing the animations i had set but it was not. I have even added my custom actions to that stack that handles the switching for the characters animation.

even with this its still not making the animations show up for the AI but the player still works.

void RPGPlayer::pickActionAnimation()
{
   // Only select animations in our normal move state.
   if (mState != MoveState || mDamageState != Enabled)
      return;

   if (isMounted() || mMountPending)
   {
      // Go into root position unless something was set explicitly
      // from a script.
      if (mActionAnimation.action != RPGPlayerData::RootAnim &&
          mActionAnimation.action < RPGPlayerData::NumTableActionAnims)
         setActionThread(RPGPlayerData::RootAnim,true,false,false);
      return;
   }

   bool forward = true;
   U32 action = RPGPlayerData::RootAnim;
   bool fsp = false;
   
   if (mEvoSP)
   {
      action = RPGPlayerData::EnvSP;
   }
   else if (mBlocking)
   {
      // Play the jetting animation
      action = RPGPlayerData::Block_High;
   }
   else if (mAttacking)
   {
      // Play the jetting animation
	  
	switch(sComboGauge)
	{
		case 0 : {
			action = RPGPlayerData::Combo1_0;         
			sComboGauge=1;
			break;
		}
		case 1 : {
			action = RPGPlayerData::Combo1_1;         
			sComboGauge=2;
			break;
		}
		case 2 : {
			action = RPGPlayerData::Combo1_2;         
			sComboGauge=3;
			break;
		}
		case 3 : {
			action = RPGPlayerData::Combo1_3;         
			sComboGauge=4;
			break;
		}
	}
      //action = RPGPlayerData::Combo1_0;
   }
   else if (mJetting)
   {
      // Play the jetting animation
      action = RPGPlayerData::JetAnim;
   }
   else if (mFalling)
   {
      // Not in contact with any surface and falling
      action = RPGPlayerData::FallAnim;
   }
   else if ( mDiving )
   {
      pickBestMoveAction(RPGPlayerData::DiveRootAnim, RPGPlayerData::DiveRightAnim, &action, &forward, true);
   }
   else if ( mSwimming )
   {
      pickBestMoveAction(RPGPlayerData::SwimRootAnim, RPGPlayerData::SwimRightAnim, &action, &forward, true);
   }
   else if ( mPose == StandPose )
   {
      if (mContactTimer >= sContactTickTime)
      {
         // Nothing under our feet
         action = RPGPlayerData::RootAnim;
      }
      else
      {
         // Our feet are on something
         pickBestMoveAction(RPGPlayerData::RootAnim, RPGPlayerData::SideRightAnim, &action, &forward);
      }
   }
   else if ( mPose == CrouchPose )
   {
      pickBestMoveAction(RPGPlayerData::CrouchRootAnim, RPGPlayerData::CrouchRightAnim, &action, &forward);
   }
   else if ( mPose == PronePose )
   {
      pickBestMoveAction(RPGPlayerData::ProneRootAnim, RPGPlayerData::ProneBackwardAnim, &action, &forward);
   }
   else if ( mPose == SprintPose )
   {
      pickBestMoveAction(RPGPlayerData::SprintRootAnim, RPGPlayerData::SprintRightAnim, &action, &forward);
   }
   setActionThread(action,forward,false,false,fsp);
}


What function holds the lowest barriar for not applying animation to an object. I can work backards from there maybe...
#29
01/23/2012 (4:13 am)
The only way I could get to work is to make a AttackState then when when detecting the Trigger for a swing I set the State to Attacking which work like the recover code. It will detect the level of attack im doing and then and only then will the NPC attack.I also had to only apply the attack animation when !isGhost(). even though when triggering the attack isChost() return true. Could this cause any future issues?

#30
01/10/2013 (2:40 am)
did u get any solution of it?

i am having same problem after adding this resource:
http://www.garagegames.com/community/resources/view/21164
#31
01/10/2013 (3:22 am)
Ill make a resource. It's a lot. Hopefully I can just diff my player and rob player class.
#32
01/10/2013 (6:02 am)
i will then wait for the resource.
thanks
#33
01/10/2013 (7:00 pm)
I was going to release my modular version of the player class but I still have some works to do. So it looks like i reverted everything backwards and the only thing i did add a new function stop action thread.

To play an animation i call:

if(%this.setActionThread("AttackSeq",false,false)){
         %this.setAttackingState(1);
      }
   }else{
      %this.dataBlock.ContinueCombo=1;
   }
}
function RPGAIPlayer::onAnimationTrigger(%this,%TriggerID,%SeqName)
{  
   if(%TriggerID<%this.dataBlock.AttackSeqLength){
      if(%this.dataBlock.ContinueCombo==0){
         %this.stopActionThread();

The code added to stopActionThread is:

//Added the ability to stop an action thread.
void RPGPlayer::stopActionThread()
{
   mActionAnimation.action = RPGPlayerData::NullAnimation;
   //setActionThread( RPGPlayerData::NullAnimation, true, false, false, false,true);
   setMaskBits(ActionMask);
}


//Added Stop Animation Thread for Animations
DefineEngineMethod( RPGPlayer, stopActionThread, void, (),,
   "\n\n")
{
   object->stopActionThread();
}
#34
01/10/2013 (7:03 pm)
To go a little more in detail.

To do the animation on the player i have to do this:

function serverCmdtriggerAttack(%this){
   %obj=%this.getControlObject();
   %obj.triggerAttack();
}
function RPGPlayer::triggerAttack(%this){
   
   if(%this.getAttackingState()==0){
      if(%this.setActionThread("AttackSeq",false,false)){
         %this.setAttackingState(1);
      }
   }else{
      %this.dataBlock.ContinueCombo=1;
   }
}

For the AI I just have to call:

function RPGAIPlayer::triggerAttack(%this){
   
   if(%this.getAttackingState()==0){
      if(%this.setActionThread("AttackSeq",false,false)){
         %this.setAttackingState(1);
      }
   }else{
      %this.dataBlock.ContinueCombo=1;
   }
}
#35
01/10/2013 (7:05 pm)
As long as its called on the server side it should work. Calling the animation client side will not work.
Page«First 1 2 Next»