x


Animations at every shot?

so i finally got my gun to play an animation on every shot with

function Update () {

if (Input.GetButton("Fire1")) { animation.Play("boltaction"); } }

But it doesn't completely satisfy me because it still happens if i'm reloading or something. How do i make it play just when the gun shots or something?

more ▼

asked Jun 23 '10 at 11:02 PM

user-3180 (yahoo) gravatar image

user-3180 (yahoo)
164 9 9 16

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

2 answers: sort voted first
if (the exact situation you will permit the animation to play occurs)
{
    playTheAnimation;
}

what you have now is:

if(the fire one button was pressed)
{
    playTheAnimation;
}

In fact the computer is simply doing exactly what you told it to do.

The quickest way to fix this is

Make a boolean called "mayShootNow" In the update check if the situation permits the animation to play, here you have to pick a parameter and use it like a door, when do you want it opened ? When the key was released? When the character is not walking? Whenever another animation is done playing? You need to figure out what the event is that permits the animation play event. Once you have that gateway setup done you need to update it.

if (mayShootNow && fire button)
{
    fireEvent (playAnimation, playSound, fireBullet)?

}
more ▼

answered Dec 07 '10 at 02:36 PM

Proclyon gravatar image

Proclyon
1.4k 10 13 32

(comments are locked)
10|3000 characters needed characters left
 function Update () {

    if ( Input.GetButton("Fire1") && !animation.IsPlaying("yourReloadAnimationName") ) { animation.Play("boltaction"); } }
more ▼

answered Jun 23 '10 at 11:27 PM

AnaRhisT gravatar image

AnaRhisT
865 30 33 43

(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
x461
x330

asked: Jun 23 '10 at 11:02 PM

Seen: 723 times

Last Updated: Jun 23 '10 at 11:02 PM