- Home /
Question by
ollie_payne · Jun 07, 2015 at 08:38 PM ·
unity 5unity5shootingshootgetmousebutton
GetMouseButton Not Working
I am trying to make a shoot script. I have done this before in other projects but for some reason it just isn't registering that I am pressing the left mouse button. I recently upgraded to Unity 5 so I am not sure if this is affecting it. Here is my shoot script:`
var bullet : GameObject;
var isShooting : boolean = false;
function Update () {
if(Input.GetMouseButton(1)) {
isShooting = true;
Shoot();
}
if(Input.GetMouseButtonUp(1)) {
isShooting = false;
}
}
function Shoot () {
while(isShooting) {
Instantiate(bullet, this.transform.position, this.transform.rotation);
yield WaitForSeconds(0.4);
}
}
Comment
Answer by Dave-Carlile · Jun 07, 2015 at 08:39 PM
According to the GetMouseButton documentation, the left mouse button is 0. You're passing in 1 so you're looking for right mouse button presses.
Your answer
Follow this Question
Related Questions
how i can use api 26 level in unity 5.x 0 Answers
How to make a tps gun [C#] 1 Answer
compute shader in order access of pixels 0 Answers
How to change animation speed in Unity 5 0 Answers