x


Only trigger when in specific animation

Hello Everyone, im new to Untiy and making an FPS game, so far, everything works fine, but I have a small problem I want it so that i can only use this

if(Input.GetButtonDown ("Shoot")){  //Click

ammo = ammo-1; //Lose  Ammo

animation.Play ("SHOOT");  
}

Only when animation IDLE is playing, so I cant shoot a second time when the shoot animation is already playing if you know what I mean

THanks in advance

more ▼

asked Aug 06 '10 at 09:57 PM

Xavier gravatar image

Xavier
3 1 1 2

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

2 answers: sort voted first

This should work:

if(Input.GetButtonDown ("Shoot") && animation.IsPlaying("IDLE")){  //Click
    ammo = ammo-1; //Lose  Ammo
    animation.Play ("SHOOT");  
}

(EDIT: corrected)

more ▼

answered Aug 06 '10 at 10:55 PM

Wolfram gravatar image

Wolfram
9.1k 8 20 53

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

i think i understand at http://www.unifycommunity.com/wiki/index.php?title=FPSWalkerEnhanced it has a modified fpswalker script and it has code to stop people jumping continuous by what they called antibunnyhop, you could adapt it for shooting, theirs a C sharp and a Javascript as well.

more ▼

answered Aug 06 '10 at 10:38 PM

Lastowl gravatar image

Lastowl
16

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

x3935
x1200
x330
x61

asked: Aug 06 '10 at 09:57 PM

Seen: 744 times

Last Updated: Aug 06 '10 at 09:57 PM