Posted: 18th Apr 2023 3:16
So I am lost or my coding is not correct. What is wrong with my code? I am trying to set a attack anim and am using GetObjectIsAnimating() and it does not work. Is there a better way to check if my attack animation is over to go back to my regular anim?

+ Code Snippet
	PlayerAnim=GetObjectIsAnimating(player)
	
	if GetRawKeyState(40) and attack=0
		MoveObjectLocalZ(player,-speed#*0.34)
		if moving = 0
			PlayObjectAnimation(player,"",596,620,1,0.2) // walk back
			SetObjectAnimationSpeed(player,60)
			moving = 1
			idle=0
		endif
	endif
	
	if GetRawKeyState(38)=0 and GetRawKeyState(40) =0 then moving = 0
    	if moving = 0 and idle=0 and attack=0 
		PlayObjectAnimation(player, "", 236,265, 1, 0.3 ) // idle
		SetObjectAnimationSpeed(player,60)
		idle=1
	endif 
	
		if GetRawMouseLeftPressed() then attack= 1
		
		if attack= 1
		moving = 0 
		idle=0
		PlayObjectAnimation(player, "", 160,189, 0, 0.1 ) // Attack
		SetObjectAnimationSpeed(player,60)
	   endif 
  
      if attack= 1 and PlayerAnim=0
	  attack=0
	  endif
Posted: 18th Apr 2023 6:19
you could try stopobjectanimation(objid) before playing the object animation


SetObjectAnimationFrame(UINT objID, animName, time, tweentime )
should work better for setting the animation to a start frame
Posted: 18th Apr 2023 13:52
limited 3D experience but i don't see a GetObjectPlaying() command which is odd.

a quick test shows that if the object is not currently playing an animation, GetObjectAnimationTime(objID) will return 0.0?
i've monitored but not sure what "or if the animation has stopped then the last time used for interpolation is returned." actually means.
i think that's refering to the built-in tween time but unsure.

otherwise, you could probably track and compare GetObjectBoneX() on a bone that should be moving, as well.
Posted: 18th Apr 2023 14:01
GetObjectIsAnimating is the default code for is it playing. There is no getobjectplaying and getobjectanimationtime just records the time it started playing but I did figure this out guys and thank you.

I guess in AppGameKit you do not need to stop a animation to start a new one so just playing the attack anim with no flag works.

+ Code Snippet
   PlayerAnim=GetObjectIsAnimating(player)

   

  
 	if  GetRawKeyState(38) or getjoystickx()>0
		MoveObjectLocalZ(player,speed#)
		if moving = 0
			PlayObjectAnimation(player,"",266,303,1,0.30) // run forward
			SetObjectAnimationSpeed(player,60)
			moving=1
			idle=0
		endif
	endif
	
	if GetRawKeyState(40)
		MoveObjectLocalZ(player,-speed#*0.34)
		if moving = 0 
			PlayObjectAnimation(player,"",596,620,1,0.1) // walk back
			SetObjectAnimationSpeed(player,60)
			moving = 1
			idle=0
		endif
	endif
	
	if GetRawKeyState(38)=0 and GetRawKeyState(40) =0  then moving = 0
    	if moving = 0 and idle=0 
		PlayObjectAnimation(player, "", 236,265, 1, 0.30 ) // idle
		SetObjectAnimationSpeed(player,60)
		idle=1
	endif 
	
	   if GetRawMouseLeftReleased()  and GetRawKeyState(38) =0 
		PlayObjectAnimation(player, "", 160,189, 0, 0.3 ) // Attack
		SetObjectAnimationSpeed(player,80)
	   endif 
	   
	    if GetRawMouseLeftReleased()  and GetRawKeyState(38) =1
		PlayObjectAnimation(player, "", 160,189, 0, 0.1 ) // Attack
		SetObjectAnimationSpeed(player,80)
	   endif 
  
      if PlayerAnim=0 and GetRawKeyState(38)=1 then moving = 0
      if PlayerAnim=0 and GetRawKeyState(38)=0 then  idle=0
Posted: 19th Apr 2023 8:57
Hi

In the doc, we can see the starttime and endtime of playerObjectAnimation() is in second, not in frame.

Your time value seems very big : (walk back for example)
PlayObjectAnimation(player,"",596,620,1,0.1)


Your animation has 620 seconds ?

If you use frame instead of second for playObjectAnimation(), you should try to change it in second.

Your attack animation doesn't use a loop, so GetObjectIsAnimating() should work when the animation of attack is finished.

(I have tried and it work with my model.)
Posted: 19th Apr 2023 18:44
Blendman Hi

I am using stock models to set this up so the animations are what they are for now.

Yes like I said for animations to play in AppGameKit I learned you do not need a flag they just play over each other and as long as you reset each flag after the attack anim it works.

Thank you for helping.