Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Animator

Discussion in 'Project Tiny' started by dallin_unity, Dec 21, 2020.

  1. dallin_unity

    dallin_unity

    Joined:
    Dec 18, 2019
    Posts:
    40
    Hi guys, component tiny animation authoring need component animator, but I can't find a way to use animator, since animator is from UnityEngine, not from Unity.Tiny.Animation, for now I can only use TinyAnimation.SelectClipAtIndex to change animation at runtime.
    The problem is I don't know how to switch the animation right away, for example when player speed set to 0, I want to change animation immediately, but right now it seems that the it need to finish the previous animation before play another animation, i want something that similar to disable "has exit time" in unity animator
    upload_2020-12-21_11-35-4.png
    Thanks for your help.
     
  2. AbdulAlgharbi

    AbdulAlgharbi

    Unity Technologies

    Joined:
    Jul 27, 2018
    Posts:
    319
    Hi
    you can do the following on system update which will wait for the current clip to finish then you can call the next clip and should be able to switch to it
    Code (CSharp):
    1.  
    2.         var duration = TinyAnimation.GetDuration(World, animationEntity);
    3.         var time = TinyAnimation.GetTime(World, animationEntity);
    4.         if (TinyAnimation.GetWrapMode(World, animationEntity) != WrapMode.Loop)
    5.         {
    6.             //Wait for the current animation to finish
    7.             if (TinyAnimation.IsPlaying(World, animationEntity))
    8.             {
    9.                 if (time < duration)
    10.                 {
    11.                     return;
    12.                 }
    13.             }
    14.         }
    15.         TinyAnimation.SelectClip(World,animationEntity, "NextClip");
    16.         TinyAnimation.Play(World, animationEntity);
    17.  
    18.  
     
  3. dallin_unity

    dallin_unity

    Joined:
    Dec 18, 2019
    Posts:
    40
    Thanks, but actually I don't want to wait for the current clip to finish, I want to switch right away if some conditions met, for example I have a walking animation for about 8 secs, an idle animation for about 8 second, when player arrived at touch destination, I want to switch to idle animation right away and don't want to wait the walking animation to finish. same when I touch the ground, I want to walk animation to play right away and don't want the idle animation to keep playing, the problem is that TinyAnimation.Play(World, entity) doesn't play the animation right away after selecting clip but instead wait until the last animation finish then play the selected clip

    I hope you understand me, I'm sorry for my poor English skill.
     
  4. AbdulAlgharbi

    AbdulAlgharbi

    Unity Technologies

    Joined:
    Jul 27, 2018
    Posts:
    319
    You need to call TinyAnimation.SelectClip before TinyAnimation.Play and if you change the selected clip,
    the animation system will immediately switch to that clip
     
    dallin_unity likes this.
  5. dallin_unity

    dallin_unity

    Joined:
    Dec 18, 2019
    Posts:
    40
    I just checked, you are right, my code was wrong, thank you so much.