x


Play Animation With GetKey

Hello, I want to play an animation. I did a script, but it doesn't works at all.

When I press "P" the animation plays all, only if I keep pressed "P". But I want to play the complete animation when I pressed "P" just once.

Here's my script:

function Update()
{
 if(Input.GetKey(KeyCode.P))
 {
 animation.Play("animationtest",PlayMode.StopAll);
 }
}

Blockquote

This is a separate script from ThirdPersonController (I'm using ThirdPersonController, too)

Any ideas?

more ▼

asked Jun 14 '11 at 10:40 PM

indexomega gravatar image

indexomega
16 3 3 4

Tried using getkeydown instead?

Jun 14 '11 at 11:47 PM FutchProductionsSyndicate

that won't help. have you tried disabling ThridPersonController?

Jun 15 '11 at 10:04 AM iggy
(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

You want to press 'P' only once is not it? Then use the GetKeyUp, which detects when you release the button, causing you to not be holding the key

Link: http://unity3d.com/support/documentation/ScriptReference/Input.GetKeyUp.html

Hope this help ^^

more ▼

answered Jun 15 '11 at 10:31 AM

Unamine gravatar image

Unamine
362 14 17 27

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

x3772
x952
x224
x90
x32

asked: Jun 14 '11 at 10:40 PM

Seen: 1275 times

Last Updated: Jun 15 '11 at 10:32 AM