Good night, I'm new in the area of programming and am having some problems with the collider. The game runs, but even when the player collides with the "Currencies", they are not destroyed or become inactive. (I tried both ways, left a comment way). Know tell me where is the error? Code (CSharp): using UnityEngine; using System.Collections; public class Personagens : MonoBehaviour { public GameObject personagem; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if (GameObject.FindGameObjectWithTag ("Personagem") == false) { Vector3 posicaoNovoObjeto = new Vector3 (0, 2, 0); Quaternion rotacaoNovoObjeto = new Quaternion (0, 0, 0, 0); Instantiate (personagem, posicaoNovoObjeto, rotacaoNovoObjeto); } } void OnTriggerEnter (Collider other) { if (other.gameObject.tag == "Moedas") { //Destroy (other.gameObject); other.gameObject.SetActive(false); } } } I also tried the following way, and kept having problems: Code (CSharp): using UnityEngine; using System.Collections; public class Personagens : MonoBehaviour { public GameObject personagem; public GameObject moedas; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if (GameObject.FindGameObjectWithTag ("Personagem") == false) { Vector3 posicaoNovoObjeto = new Vector3 (0, 2, 0); Quaternion rotacaoNovoObjeto = new Quaternion (0, 0, 0, 0); Instantiate (personagem, posicaoNovoObjeto, rotacaoNovoObjeto); } } void OnTriggerEnter (Collider moedas) { //Destroy (moedas.gameObject); moedas.gameObject.SetActive(false); } } Thank you so much!
I managed to find the error. The problem was that I have the gameObject character inside another empty gameObject, and I was putting the script in the empty gameObject.