Quantcast
Channel: Questions in topic: "count"
Viewing all articles
Browse latest Browse all 187

So how do I fix Count error?

$
0
0
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Scriptsphere : MonoBehaviour{ private Rigidbody rb; private int count; public Text countText; void Start() { rb = GetComponent (); count = 0; setCountText (); } void FixedUpdate() { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical"); Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); rb.AddForce (movement); } void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag ("pickup")) { other.gameObject.SetActive (false); count = count + 1; setCountText (); } } void setCountText() { countText.text "Count: " + count.ToString (); } } So what is wrong with this code? countText.text "Count: " + count.ToString ();

Viewing all articles
Browse latest Browse all 187

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>