Hello,
what i have is a GUI with buttons. I want them to play a certain animation on my character.
I have little knowledge about unity…after an hour googling i was able to find this:
GameObject.Find("MyGameObjectID").animation.Play("Animation-ID"))
I tried to combine it to:
if(GUILayout.Button (itemVar, GUILayout.Height (50)))
{
GameObject.Find("MyGameObjectID").animation.Play("Animation-ID"))
}
which was not working.
Help please
Solution:
you have to exlude the animation in the ThirdPersonController with
public var animationActive = 0;
Player.GetComponent("ThirdPersonController").animationActive = 1;
Player.animation.Stop();
Player.animation["Button"].wrapMode = WrapMode.Once;
animate();
function animate()
{
Player.animation.Play("Button");
yield WaitForSeconds (Player.animation["Button"].clip.length);
Player.GetComponent("ThirdPersonController").animationActive = 0;
}