question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Loopable animations not working with AnimationStateReference play extension

See original GitHub issue

I’m using this code for previewing animation states out of playmode in the editor;

/// <summary>
/// Script to change animation states in editor to preview states in scene
/// </summary>

#if UNITY_EDITOR
[RequireComponent(typeof(Animator))]
[ExecuteInEditMode]
public class AnimationStateInEditor : MonoBehaviour
{
    [AutoProperty, ReadOnly, SerializeField]
    private Animator anim;
    
    public AnimationStateReference state;

    private void OnValidate()
    {
        anim = GetComponent<Animator>();
    }

    private void Update()
    {
        if (!Application.isPlaying)
        {
            //forces to play in edit mode
            anim.Update(Time.deltaTime);
            anim.Play(state);

        }
            
    }
}
#endif

While normal animations work fine, loopable animations only plays the first few frames over and over - not the entire animation. Am I doing something wrong here?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Deadcowscommented, Mar 2, 2020

Share your results when this tool is done if it’s possible 😉 I’d like to see how you’re using this animation preview mode in your game🤓

0reactions
Deadcowscommented, Feb 28, 2020

Yep, it simply plays animation on the Animator with all the translations and stuff. To separate particular animation you probably need to parse animator controller to receive AnimationClip asset, construct new playable graph on the fly and inject your clip asset and playable output (animated avatar). It’s been a while since I dabbled with playables, but it should be relatively easy to do the thing you want There are some links that may help: Playable example, SimpleAnimation example project and also it seems that legacy Animation component might work

Read more comments on GitHub >

github_iconTop Results From Across the Web

Animations not looping : r/godot
I have been working on a small project, and I'm simply trying to get my animations to play properly by using the animation...
Read more >
Animation loop doesn't work - Scripting Support
Hello, so I've made a very simple script to play a looped animation when the tool is equipped. local tool = script.
Read more >
Animations not looping on inherited scenes from a 3D gltf ...
Select the animation player and set an animation to autoplay and loop; Create a scene to see the character in the game; Play...
Read more >
Loop animation not working - Getting Started & Setup
I made a simple animation with the starter pack. I dragged SK_mannequin and added Jog_Fwd animation, and then let it run from the...
Read more >
Thread: Looping Animation (walk cycle) not working
Looping Animation (walk cycle) not working. Hello, So this is my first post on the clickteam fourms. Hi everybody! So I've come to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found