Hi. I am having trouble with a project I’ve been working on. I have an object and I need it to change materials when the player collides with it. I followed a tutorial and it originally worked perfectly, but it just stopped registering the material array in the inspector one day and I can’t work out why. All the collisions and everything works it is literally just the array. Here is my code:
If the OnCollisionEnter function is not called, there are 2 reasons.
First, the OnCollisionEnter function could not be called because of inappropriate collider&rigidbody setting. You can simply check it with Debug.Log() in OnCollisionEnter. About collision check this: Unity - Manual: Introduction to collision. Scroll down below and see collision action matrix.
Second, It is not called if you disabled physics collision between layers or colliders. Go to Edit/Project Setting/Physics and check Layer Collision Matrix. Also, check if you are using Physics.IgnoreCollision or Physics.IgnoreLayerCollision. Hope this helps you.