- Home /
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 "$$anonymous$$yGameObjectID" 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 ' ; '
the semicolon is there. it is because of the 3rd person character controler. i need to change the character state because it is recalling another animation in the update function. so how to acces the script from the GUI script???
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);
Answer by BerggreenDK · Aug 07, 2011 at 10:14 PM
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.
what's the fu*k??? i am not going to read it. i would rather take the documentation...
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.
just google the beginner question 90% is the same useless replies like this here. am not even close to you what you talking about fnord.