Loopable animations not working with AnimationStateReference play extension
See original GitHub issueI’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:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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🤓
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