- Home /
Animation Issue
Let's say we've got a simple script:
if
(Input.GetButton ("Aiming") && Input.GetButton ("Action")){
animation.CrossFade("shoot");
}
But if I let "Action" button up almost immediately or trying to press the button very fast the animation clip doesn't play till the very end. Is there any solution to make animation play it's full length, so that the next action (button press) will be available only after animation's finished? Thanks in advance for your help :)
Answer by Sirmaiji · Sep 01, 2013 at 05:42 PM
The animation is not playing. Using this code leads to disabling "shoot" animation at all.
Did you copy-paste my code or retype it? Try copy-pasting. I think you missed the "!" before animation.IsPlaying...
I was on a cell phone didn't see your post :) I use that for $$anonymous$$e without the '!' I deleted my comment as it was irrelevant given your answer was saying the same thing.
Answer by KuPAfoo · Sep 01, 2013 at 06:58 PM
your recognizing both the aim button and the fire button to cause the shoot animation.
to test this remove the aiming portion of the if statement
run code
use fire button
if you can fire successfully, make a nested if statement
(if"aiming") { show crosshair (if"action") {play"shoot"}//end ifaction }//end if aiming
Guess somehow I've found the way out. Here's what may be helpfull for those who might have the same issue:
if
(Input.GetAxis ("Vertical") < 0.0 && (Input.GetButton ("Action")) && (Input.GetButton ("Ai$$anonymous$$g"))){
animation.CrossFade ("shoot_down");
animation["shoot"].normalizedTime = 0.5;}
else {
if
(Input.GetAxis ("Vertical") > 0.0 && (Input.GetButton ("Action")) && (Input.GetButton ("Ai$$anonymous$$g"))){
animation.CrossFade ("shoot_up");
animation["shoot"].normalizedTime = 0.5;}
else {
if
(Input.GetButton("Ai$$anonymous$$g")){
if
(Input.GetButton("Action")){
animation.CrossFade("shoot");
animation["shoot_up"].normalizedTime = 0.5;
animation["shoot_down"].normalizedTime = 0.5;}}
But still got an issue with just "shoot" (forward) action. I can't add animation["shoot"]"normalizedTime" to "shoot" animation neither to "Ai$$anonymous$$g" input, nor to "Action" (last 5 code lines). The thing is, when those two buttons pressed all the animation being stuck. I guess the problem's in contradiction between variables "animation.CrossFade("shoot")" and animation["shoot"]"normalizedTime". Still wanna find out how to solve that...
Your answer
Follow this Question
Related Questions
Loop animation on button hold 2 Answers
Crazy weird input script order glitch please help! 1 Answer
Animation can't find my animations 1 Answer
GetButton Problem 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers