I made 2 simple objects, marked um isTrigger and the other no. I made 2 codes, where:
Trigger:
public class Gatilho : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Debug.Log("Deveria avisar");
}
void OnCollisionEnter (Collision other)
{
if (other.gameObject.CompareTag("Player"))
{
Debug.Log("Colidiu");
}
}
}
Another object movement:
public class MOve : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.position = transform.position + new Vector3(0,0, -2f * Time.deltaTime);
}
}
So for when an object is marked as is trigger, you need to use OnTriggerEnter. Other than that the inspector gets cut off early so I can’t tell but make sure one of the objects have a rigibody attached to it otherwise it won’t work.
Preferably the player gets the rigibody if it has one try putting a debug.log into the collision method but outside of the if statement.