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;
}
You should start with one of the many great tutorials. There is nothing technically wrong with the above, so the problem is elsewhere.
– WazJust to be on the save side... you did replace "MyGameObjectID" with the actual name of your Object and "Animation-ID" with the actual name of your animation, yes? (sorry if 'of course you did this'. just checking...)
– SisterKyah, wait! There is one thing wrong: You have to replace the last ' ) ' with a ' ; '
– SisterKymaybe you should have said that to begin with? So don't go all '???' on us. You don't pay us to help you or anything, do you? shakes her head GameObject.Find("TheObject").GetComponent(Character Controller);
– SisterKy