So first: I’m fairly new to Unity, so bear with me.
I have a scene that contains 4 walls and dynamically generates objects within based on JSON. The walls all have box colliders and a script which contains
void OnCollisionEnter(Collision col)
{
Debug.Log("Collision ");
if (col.gameObject.tag == "Road")
{
Debug.Log("with Road");
}
}
The “roads” are generated and within an Initialize function I add a Box Collider:
BoxCollider collider = roadPlane.GetComponent<BoxCollider>();
collider.size = new Vector3(10f, 0.1f, 10f);
When playing the scene, I can definitely see the colliders from the wall and road intersecting, but the OnCollisionEnter function doesn’t appear to execute.
Any help is greatly appreciated. Thanks in advance!