x


Start Animation On Trigger

Hi, So I made a basic animation and attached it to a sword. (First Person MMO?) It will make the sword swing. But I am not a scripter!!! How do I start this animation when I press a certain button??? I want to swing the sword by clicking the mouse. Is this a trigger??? Please help!

more ▼

asked Aug 03 '10 at 02:49 PM

Collinbxyz gravatar image

Collinbxyz
109 23 24 33

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Nope it's not a trigger. Check what Unity has named your mouse button by going in Edit->Project Settings-> Input. Then simply create a new Javascript and write these down under function Update.

if(Input.GetButtonDown("MouseButtonName")) {

animation.CrossFade("name of the animation");

}

This should be simple enough. Make sure you've assigned the animation to the object and assign this code to your sword. It should work.

more ▼

answered Aug 03 '10 at 03:00 PM

scarletsnake gravatar image

scarletsnake
76 4 6 9

The animation to what object??? BTW Thx For the help.

Aug 03 '10 at 03:07 PM Collinbxyz
(comments are locked)
10|3000 characters needed characters left

You should make sure that in the Inspector Window your Sword object should have the name of the animation that you're going to use under the "animation" box. Click on your Sword object, in the Inspector Window there should be a part called "Animation". There's usually a standard one that comes with the model. Add your animation there. Hope this helps.

This could also be useful;

http://unity3d.com/support/documentation/Manual/Character-Animation.html#IntoScene

more ▼

answered Aug 03 '10 at 05:48 PM

scarletsnake gravatar image

scarletsnake
76 4 6 9

(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:

x3774
x3327
x982
x104
x88

asked: Aug 03 '10 at 02:49 PM

Seen: 5242 times

Last Updated: Aug 03 '10 at 02:49 PM