I'm new with the unity and just wanted to check the OnTriggerEnter function if it is working or not.
So I just added this code to check, but there is no output in my console.
private void OnTriggerEnter(Collider other)
{
Debug.Log("hit: " other.transform.name);
}
And I enabled isTrigger for all the gameObject.
CodePudding user response:
Both GameObjects must contain a Collider component. One must have Collider.isTrigger enabled, and contain a Rigidbody. If both GameObjects have Collider.isTrigger enabled, no collision happens. The same applies when both GameObjects do not have a Rigidbody component.
From the docs: https://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html