Getting Started with Unity by Unknown

Getting Started with Unity by Unknown

Author:Unknown
Format: epub, pdf


Play the scene and check that the mouse cursor is hidden after the first shot.

Let's display and update the number of ammunitions left:

Open the script shootBullets.

Add the following line at the start of the script:public var nbBullets:int;

Add the following code inside the Start function:nbBullets = 0;

Modify the function Update as highlighted in the following code:function Update () { if (Input.GetButtonUp("Fire1")) { if (nbBullets >= 1) { var hit : RaycastHit; var ray = Camera.main.ScreenPointToRay (Vector3(Screen.width/2,Screen.height/2)); if(Physics.Raycast (ray, hit, 100)) { print(hit.collider.gameObject.tag); } nbBullets--; print("nbBullets:"+nbBullets); } } }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.