- Home /
2D game animation is running
Hi,
I'm making a 2D game and I have a character with some animations; I need to know in the script which animations are playing in the animator. If he is jumping, walking, attacking or something else.
Thank you :)
animations ? of what ?
are you using mechanim ?
http://docs.unity3d.com/ScriptReference/Animator.html http://docs.unity3d.com/ScriptReference/Animator.GetCurrentAnimationClipState.html
?
You definitely have to write wayyyyyy more details in your question and ESPECIALLY have a more specific title if you want answers.
Answer by Ben-Stoneman · Jun 13, 2014 at 03:10 PM
Hi Aled,
If this is for debugging purposes then you can simply look at the Animator window and you will see what animation is playing by the loading bar on the state. Also as the animation transitions are put into effect by the change in variables and then the act of assigning the variable changes to the variables in the animator you can place Debug.Logs in your scripts.
If it is for the player to see, then see here:
http://docs.unity3d.com/ScriptReference/AnimatorStateInfo.html
http://docs.unity3d.com/ScriptReference/AnimatorStateInfo-nameHash.html
The animator will not give you the animation name, but instead it will give you a number (nameHash), use the number to see the state it is attached to and set up a manager to display the animation that is playing from knowing it's nameHash.