- Home /
Question by
manueldel99 · Mar 22, 2014 at 01:10 PM ·
errorgunaiming
FPS aiming script doesn't do nothing
I've got this script:
var animator:Animator;
function Start(){
animator=GetComponent(Animator);
}
function Update () {
if (Input.GetButtonDown ("Fire2") && !animator.GetBool("aimingMode")) {
animator.SetBool("aimingMode", true);
aimingMode = true;
}
if (Input.GetButtonDown ("Fire2") && animator.GetBool("aimingMode")) {
animator.SetBool("aimingMode", false);
aimingMode = false;
}
}
In the animator I've got a default state with no animation. Then there is a transition to the aiming state that happens when aimingMode is true. After that I've got a transition (that happens when aimingMode is false) to another state, which has the same animation as the previous state, but with speed -1 so the gun returns to its original position. Finally there is a transition to the first state (the one with no animation) with the exit time condition.
When I only had the first part of the script: var animator:Animator;
function Start(){
animator=GetComponent(Animator);
}
function Update () {
if (Input.GetButtonDown ("Fire2") && !animator.GetBool("aimingMode")) {
animator.SetBool("aimingMode", true);
aimingMode = true;
}
}
I tested it and It worked, but now, nothing happens when I press Fire2.
Comment
Your answer
Follow this Question
Related Questions
Gun Script Error (Fixed!!!) 1 Answer
Problem doing a script. 2 Answers
Error line 22! Help. i dont know why? 1 Answer