- Home /
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?
Answer by AnaRhisT · Jun 23, 2010 at 11:27 PM
function Update () {
if ( Input.GetButton("Fire1") && !animation.IsPlaying("yourReloadAnimationName") ) { animation.Play("boltaction"); } }
Answer by Proclyon · Dec 07, 2010 at 02:36 PM
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)?
}
Your answer
Follow this Question
Related Questions
Shooting & Animation Problem 1 Answer
Making an animation start when my gun fires 2 Answers
Gun Animate when it shoots 3 Answers
Gun and hand animation tutorial! 2 Answers