Animation is not playing problem
See original GitHub issueHi there, I have created a simple animation using Dragonbone pro, now when I want to use that animation in unity it stuck on last frame in another word no animation is played but stack on one frame. Here is the code I use:
`using System.Collections; using System.Collections.Generic; using UnityEngine; using DragonBones;
public class Player : MonoBehaviour {
private UnityArmatureComponent player;
// Use this for initialization
void Start () {
player = this.gameObject.GetComponent<UnityArmatureComponent>();
}
// Update is called once per frame
void Update () {
if(Input.GetKey(KeyCode.LeftArrow)) {
player.animation.Play ("walk", -1);
} else if(Input.GetKey(KeyCode.LeftArrow)){
player.animation.Play ("walk", -1);
} else {
player.animation.Play ("stand", -1);
}
}
} `
Any help is much appreciated.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
CSS Animations Not Working? Try These Fixes
Another reason why your animation isn't working might be that you're attempting to animate a CSS property that isn't animatable. Check our list ......
Read more >Animation not playing correctly - Scripting Support
I have successfully scripted a “swing bat” animation, but it does not play fully. The ingame result is here: And the actual Animation...
Read more >Animator not playing animations
I'm new to unity trying to set up a simple UI that makes a wolf 3D character sit. I set up a two...
Read more >Pressing "Play Animation" Not Doing Anything
In may case "Play animation" button played one frame forward and played normally backward. There was no sound.
Read more >What should i do if animation is not working
Okay thanks. The first thing I suggest is to make sure all the options under [your profile icon] > Photos settings > Photo...
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
No problem!
So basically before, an animation was being started every frame, and usually the same animation. DragonBones won’t check whether that animation is already playing and ignore the new Play call, so it will start the animation from its first frame every Update call. So the animation never gets past the first frame.
Perhaps Unity’s animation checks whether that animation is already playing and so doesn’t start it from the beginning again, but it’s a bit more complicated because it uses states.
If you want to check whether an animation is already playing, you can call:
player.animation.GetState("Walk").isPlaying;
This might be cleaner than the code I was providing! And then only call Play(“Walk”) if that animation is not playing.
The issue here is that every update you are starting an animation. This means either the walk or stand animation is starting every single frame, so it never goes past the first frame.
This might work a bit better:
The gist of it is you only play the stand animation the frame that the player stops moving completely.