RPG like GUI character control

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.

–

Just 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...)

–

ah, wait! There is one thing wrong: You have to replace the last ' ) ' with a ' ; '

–

maybe 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);

–

1 Answer

1

I think you should go and study the lessons here first.

http://www.unityscript.com/lessons1/basics.php

Its a good start if you are beginning with Unity3D.

Dude! Why are you acting all offended? If it took you an hour of googling to get this line, the assumption is not so far-fetched that you probably are a complete beginner. The documentation is not meant for complete beginners and I know for myself that I had a really hard time to sap some information out of it. This tutorial, by contrast, IS and I would have LOVED, if someone could have pointed me to it when I started out. Unfortunately it did not exist then. It may have a super-noob 'look and feel' to it, but its content is valid info. If you don't want to take advice, feel free to leave.

–

[The documentation is excellent.][1] [1]: http://unity3d.com/support/documentation/ScriptReference/

–