OnCollision Enter function is not being read
I have a cylinder and a cube. This script is attached to the cube so it will change color upon collision with the cylinder. The OnCollisionEnter function is not being called at all, even if I just have it print. I have tried almost everything. Both of these objects are rigidbodies and have colliders attached to them. Any help would be appreciated, thank you.
public class cylindertarget : MonoBehaviour { public Color EndColor = Color.red;
void Start () {
}
void onCollisionEnter(Collision col)
{
if (col.gameObject.tag == "Pickupable")
{
Debug.Log("hit", gameObject);
gameObject.GetComponent<Renderer>().material.color = EndColor;
}
}
}
Answer by Lycanthope · Jun 02, 2017 at 01:20 AM
Make sure the tag is right and rename onCollisionEnter to OnCollisionEnter.
Your answer
Follow this Question
Related Questions
OnCollisionEnter2D is called after object was shifted 1 Answer
Colliding multiple enemys but only one at a time attacked 1 Answer
Adding OnCollisionEnter to instantiated object not working properly! 0 Answers
CS1525 Unexpected symbol '=', HELP!!! 2 Answers
How can i store all colliders of colliders which collide with a prefab? 1 Answer