x


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;
}
more ▼

asked Aug 07 '11 at 09:10 PM

kabel gravatar image

kabel
66 1 2 2

You should start with one of the many great tutorials. There is nothing technically wrong with the above, so the problem is elsewhere.

Aug 07 '11 at 09:54 PM Waz

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

Aug 07 '11 at 10:07 PM SisterKy

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

Aug 07 '11 at 10:09 PM SisterKy

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???

Aug 07 '11 at 10:21 PM kabel

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

Aug 07 '11 at 10:30 PM SisterKy
(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

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.

more ▼

answered Aug 07 '11 at 10:14 PM

BerggreenDK gravatar image

BerggreenDK
2.4k 54 62 75

what's the fu*k??? i am not going to read it. i would rather take the documentation...

Aug 07 '11 at 10:20 PM kabel

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.

Aug 07 '11 at 10:35 PM SisterKy

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.

Aug 08 '11 at 06:19 PM kabel
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3929
x1081
x230
x211
x40

asked: Aug 07 '11 at 09:10 PM

Seen: 1227 times

Last Updated: Aug 08 '11 at 07:46 PM