|
Made a cannon and animated inside unity. it has a muzzle brake that moves backwards when fired. the animation works but i cant get the script to make it work in game play. I need to have it play the animation when the w key is pressed down once. here is the script i.m trying to use any help would be appreciated.
(comments are locked)
|
|
Maybe something like this will work: Based on the layers of your other animations this should play. If not, try adding this below the if statement
(comments are locked)
|

Looking at the code, one thought would be that the body of the if statment is not being executed. Place a "print" statement before the animation.play to see if it is being reached.
Personally, I would use the following:
if (Input.GetKeyDown(KeyCode.W)) ...
Also, when posting here, try and ensure that the format of the code is correct as it is difficult to read unformatted code.