Hello, so I have this script attached to a gun my first person controller has. What it does is it plays an animation that zooms in and out the gun when the right mouse button is pressed. What i need it to do is when I first press the right mouse button, it plays the zoom animation on my gun and creates a variable called counter which has a int. value set to 1. Next, I need an if statement under function update that tests for is counter is = to 1. Then it tests if the right mouse button is clicked. If it is true, it will play a gun zoom out animation and reset counter to 0. I have a script below but I get the error, their is already a local variable, counter. The script is bellow in java script.
#pragma strict
var Gun : Transform;
function Update () {
if (Input.GetButtonDown("Fire2"))
{
var Counter : int = 1;
Gun.animation.Play("Gun Zoom");
}
if (Counter == 1)
{
if (Input.GetButtonDown("Fire2"))
{
var Counter : int = 0;
Gun.animation.Play("Gun Zoom Out");
}
}
}
Thanks in advance
↧