About Store Forum Documentation Contact



Post Reply 
Non Looping Animations *Solved*
Author Message
Khyrid Offline
Member

Post: #1
Non Looping Animations *Solved*
I must be missing something very simple here.

Based on what I saw in the Esenthel Tutorials I did this;

Code:
if(Kb.b(KB_A)) // when A pressed
      {
         skel.animate("My Animation dropped here",  Time.time()); // animate
      }

It works if I have the attack animation set to looping, but isn't there a way to have it just play an animation once? If I turn off looping, it will play once (I assume because it is using Time.time) but not again.

I can't find any example of playing a single animation 'not looped' once anywhere. I googled it, I searched these forums and I checked the bloody massacre demo. That demo uses a little more advanced way of doing the animations, so I can't make any sense of it yet.

I can get it to work if I control the duration with a variable, but it seems redundant to have to do that. I feel like I should be able to just do this;

Code:
if(Kb.bp(KB_A)) // when A pressed
      {
         skel.animate("My Animation dropped here",  PlayOnce); // animate
      }

And that would be it instead I need to do this;

Code:
float attackPlay = 0.0;
  
      if(Kb.b(KB_A) &&  attackPlay < 0.67) // when A pressed
      {
         attackPlay += 0.01;
         skel.animate("My Animation dropped here",  attackPlay); // animate
      }else{attackPlay = 0;}
(This post was last modified: 10-27-2016 01:14 AM by Khyrid.)
10-26-2016 06:11 AM
Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Member

Post: #2
RE: Non Looping Animations
hey,
i believe those are called "Motion" in EE, check out the struct Motion // Animation Motion, helper class for playing a single Animation

even tho you can use animation for one time animation as well, you might want to try this, as its used specialy for one time animation smile
(This post was last modified: 10-26-2016 06:44 AM by RedcrowProd.)
10-26-2016 06:41 AM
Find all posts by this user Quote this message in a reply
Khyrid Offline
Member

Post: #3
RE: Non Looping Animations
(10-26-2016 06:41 AM)RedcrowProd Wrote:  hey,
i believe those are called "Motion" in EE, check out the struct Motion // Animation Motion, helper class for playing a single Animation

even tho you can use animation for one time animation as well, you might want to try this, as its used specialy for one time animation smile

Thanks, I think that's what I need. No idea how to use the class though.
This is what I'm stupidly trying;

Code:
AnimatedSkeleton skel;
Motion down;

//Int here
//Shut here

bool Update()
{
   //KB Esc quit here

      skel.clear();
      if(Kb.bp(KB_D))
      {
         skel.animate(down true);
         down.set(skel, "My Down Animation");
         down.updateAuto(3,3,1);
      }
      
      skel.updateMatrix    (MatrixIdentity);
      skel.updateVelocities(              );

   return true;
}

//Render stuff here

This almost works, I see the first frame of the animation play then it stops.
(This post was last modified: 10-26-2016 11:15 AM by Khyrid.)
10-26-2016 07:10 AM
Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Member

Post: #4
RE: Non Looping Animations
that's because the down.updateAuto(3,3,1); and skel.animate(down , true); needs to be playing every single frame, and for that it cannot be in the if(Kb.bp(KB_D)){}

you can leave it in the update fonction by itself smile
(This post was last modified: 10-26-2016 04:00 PM by RedcrowProd.)
10-26-2016 03:59 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Non Looping Animations
skel.animate("My Animation dropped here", Time.time()); // animate
You can't use Time.time for this, because you need to reset the time value to 0 when you want to play from the start. So you need to use "flt time=0" and increase it by Time.d() every frame.

If you want to use Motion, then:
initialize it once at the start of animation
update it and apply to skeleton every frame

if(Kb.bp(KB_D)) down.set(skel, "My Down Animation");

down.updateAuto(3,3,1);

skel.clear();
skel.animate(down);
skel.updateMatrix..
10-26-2016 10:22 PM
Find all posts by this user Quote this message in a reply
Khyrid Offline
Member

Post: #6
RE: Non Looping Animations
I was so close to figuring that out. Guess I was too tired last night. Thanks.

My original problem is solved, but I noticed another thing once I got the animation working.

I am testing 3 animations; Go down, Be down, Get up

Go down and Get up are using motion while Be down is a looping animation that I am using the regular animation for.

When the first Go down animation finishes and the Be Down begins, the character moves up and then when go down plays it jumps back down again.
This causes a very noticeable fidgeting in the animation. Also note that this Z axis jump between animations only occurs when using motion.

I think the issue is related to the BIP of the model being moved for the be down animation and when the animations are blended, it causes a weird jump. I'm not sure why this occurs though. It works fine in 3DsMax and Unity, the feet should always be planted on the ground, so I know it's not an issue with the animations. If I don't use motion, there is no vertical jump between animations.
(This post was last modified: 10-27-2016 02:28 AM by Khyrid.)
10-27-2016 01:14 AM
Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Member

Post: #7
RE: Non Looping Animations *Solved*
this might be caused by updateAuto, i kinda feel you need to find your magic numbers for smooth in and smooth out, try putting ridiculous number like 500, it will make the animation not have this laps time smile
10-27-2016 03:00 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #8
RE: Non Looping Animations *Solved*
After finished an animation, Motion will blend it out (fade out).
Perhaps you don't want to fade out that animation, but immediately proceed to the next one.
So you can use Motion.updateIn instead of updateAuto, and when updateIn returns false, immediately delete that motion, and start playing the other looped animation.
10-27-2016 04:25 AM
Find all posts by this user Quote this message in a reply
Khyrid Offline
Member

Post: #9
RE: Non Looping Animations *Solved*
Hmm, after tweaking the blend times, I was able to go from Motion animation to loop with no problem, but I get the model jumping up briefly when going from loop to motion. I tried to change the flt blend value but anything other than 1 causes it to be even worse.

I got it, indeed it was the blend speed in update, I went ahead and used updateIn(500,1); and carefully adjusted the time that the animation should play.

It works fine now, but I still ended up using a variable for timing how long each animation should play. Motion ended up being more complex then just making everything a loop animation and controlling it with a variable.

In any case; I think I figured out enough to be able to add 3d animations now. Thanks for the help guys.
(This post was last modified: 10-27-2016 04:55 AM by Khyrid.)
10-27-2016 04:48 AM
Find all posts by this user Quote this message in a reply
Post Reply