Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

why does this script show context error ?

$
0
0
The script is :`using UnityEngine; using UnityEngine.UI; using System.Collections; public class PlayerController : MonoBehaviour { public float speed; public Text countText; public Text winText; private Rigidbody rb; private int score; void Start () { rb = GetComponent(); score = 0; winText.text = ""; } void FixedUpdate () { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical"); Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); rb.AddForce (movement * speed); } void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag ( "Pick Up")) { other.gameObject.SetActive (false); score = score + 1; SetCountText (); score = 8 } } void SetCountText() { countText.text = "score: " + score (); // Error : the name 'score' does not exist in the context. if (score >= 12) { winText.text = "You Win!"; } } } `

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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