Quantcast
Channel: Answers for "How to make a certain object disappear after a set amount of pickups is collected?"
Viewing all articles
Browse latest Browse all 9

Answer by rodrigodelucaetuma

$
0
0
I solved it with a destroy command line! using UnityEngine; using System.Collections; public class playercontrol : MonoBehaviour { public float speed; public GUIText countText; public GUIText winText; private int count; void Start () { count = 0; SetCountText (); winText.text = "Chabiliii! Mova a bola usando as flechas do teclado e recolha os cubos!"; } void Update () { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical"); Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); GetComponent().AddForce(movement * speed * Time.deltaTime); } void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "pickup") { other.gameObject.SetActive (false); count = count + 1; SetCountText (); } } void OnCollisionEnter (Collision col) { if(col.gameObject.name == "levelwall" && count >= 12) { Destroy(col.gameObject); } } void SetCountText (){ countText.text = "Pontos: " + count.ToString (); if (count >= 5) { winText.text = ""; } if (count >= 12) { winText.text = "Parabens Chabiliiii!!! Agora derruba a parede!!!"; } } }

Viewing all articles
Browse latest Browse all 9

Trending Articles