- Home /
How to get an animation script working?
I'm having trouble getting the proper animation to play for my game. It is a first person shooter where the players weapon is a bow. I currently have it set up so that all you need are two animations. The idle animation and the shoot/reload animation.
I am trying to get a script written where the bow is ready to shoot (which is the idle animation) and when the player clicks, the arrow is shot and the character in game reloads the bow and gets the arrow ready for another shot. I have all the components working for the shooting and fire delay. I just need to understand how to get the animations working. I have little no to experience in scripting, but I was able to get this (by looking through tutorials and manuals) so far. I know its not right, but it's what I have so far.
var Idle : AnimationClip;
var Shoot : AnimationClip;
function Update ()
{
if (Input.GetAxis("Fire1"))
animation.Play("Shoot");
else
animation.Play("Idle");
}
Using this code, the animation will play, but only while the mouse button is held down. As soon as I let go, the animation snaps back to its idle. How would I get the animation to play through until its finished? And also have it so that when the player clicks again, it doesn't restart the animation? Thank you in advance.
Your answer
Follow this Question
Related Questions
I need help writing an animation script for a Bow and Arrow weapon 1 Answer
Animation Not Playing 1 Answer
CharacterController walks through wals/Objects 1 Answer
my animation script does not work 0 Answers
Unity3D AI using animations 1 Answer