I am a first time beginner at scripting and I am making a FPS and you have to pick up ammo and it shows on the screen how much ammo you have. I can’t figure out what is causing this error. Here is the script:
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public float movementSpeed = 5.0f;
public float mouseSensitivity = 7.0f;
float verticalRotation = 0;
public float UpDownRange = 60.0f;
public GUIText countText;
private int count;
// Use this for initialization
void Start ()
{
Screen.lockCursor = true;
count = 0;
SetCountText ();
}
// Update is called once per frame
void Update ()
{
//rotations
float rotLeftRight = Input.GetAxis ("Mouse X");
transform.Rotate (0, rotLeftRight, 0);
verticalRotation -= Input.GetAxis ("Mouse Y");
verticalRotation = Mathf.Clamp (verticalRotation, -UpDownRange, UpDownRange);
Camera.main.transform.localRotation = Quaternion.Euler (verticalRotation, 0, 0);
//movement
float forwardspeed = Input.GetAxis ("Vertical") * movementSpeed;
float sidespeed = Input.GetAxis ("Horizontal") * movementSpeed;
Vector3 speed = new Vector3 (sidespeed, 0, forwardspeed);
speed = transform.rotation * speed;
CharacterController cc = GetComponent<CharacterController> ();
cc.SimpleMove (speed);
}
void OnTriggerEnter(Collider other)
{
countText.text = "Count: " + count.ToString ();
}
{
if (other.gameObject.tag == "PickUp")
{
other.gameObject.SetActive (false);
count = count + 1;
SetCountText ();
}
}
{
void SetCountText ()
}
}