- Home /
OnTriggerEnter2D & OnCollisionEnter2D Not Responding
Recently I've been having a lot of trouble with the OnTriggerEnter2D and OnCollisionEnter2D functions. when i first implemented it, there were no problems. But now the function never gets called even when I do log it into the debugger. My Player GameObject just goes through the other GameObject I want it to interact with. I've looked everywhere online and tried the many solutions people have suggested for this issue but they were unsuccessful.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Detonate : MonoBehaviour {
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player")
{
Debug.Log(other.name);
Destroy(other.gameObject);
Destroy(gameObject);
}
}
}`
how is one Object moved into the other? Or differently put: let one of them physically fall through the other the unity way with rigidbody not kinematic. if that triggers, the move code is wrong.
Answer by Kryloth · Mar 06, 2018 at 05:31 AM
Because you didn't check Simulated inside the Rigidbody2D in the Inspector for the GameObject, Unity will ignore anything the GameObject do with the Physics Engine because the Rigidbody isn't Simulated.
"When not simulated, any attached Collider2D or Joint2D also do not participate in the physics simulation."