No idea what to do here

#pragma strict

var BulletNumber : float;

function Update () {
if (Input.GetMouseButtonDown(0)) {
BulletNumber–;
}

}

Still pretty new to scripting.

So I put the script into a gameobject, and type the number I need in the BulletNumber variable. Whenever I click my mouse button, I shoot a Sphere, and one is taken off of BulletNumber . Problem is, I don’t know how to tell Unity to disable the Sphere when the BulletNumber reaches 0.

Help please?

I’m sure you have an if statement that shoots a sphere when the left mouse button is clicked. Just change that to “if the left mouse button is clicked and BulletNumber above zero”.

1 Like

Since you are pretty new, I do suggest you look into basic programming tutorials as well as intro to unity stuff. There are tons of videos and text examples. If statements are pretty basic and will usually be covered in these areas. Plus, you’ll learn a lot more to go with it!

Check out the Learn section, if you haven’t already. There are lots of helpful tutorials.

Try this.

#pragma strict

var BulletNumber : float;

function Update () {
if (Input.GetMouseButtonDown(0) && BulletNumber >  0) {
BulletNumber--;
}

}
1 Like