OnCollisionEnter not working ?

I cant tell whether im just being stupid or my unity is broken. I’ve watched almost every tutorial i can find and this always seems to work for them. here is my script;

using UnityEngine;
using System.Collections;

public class collectables : MonoBehaviour {
public bool test;

// Use this for initialization
void Start () 
{
	test = false;
}

// Update is called once per frame
void Update () 
{

}
void OnCollisionEnter(Collision other)
{
	if (other.gameObject.name == ("Cube")) 
	{
		test = true;

	}
}

}

thanks

This question gets asked a lot, and the response is always the same…

  • Do you have colliders attached to both objects?
  • Not marked as “Is Trigger”?
  • Do you have a rigidbody attached to at least one of the objects?
  • Not marked as “Is Kinematic”?
  • Is the other object with which you’re colliding called “Cube”?

If you answered “no” to any of these questions, there’s your problem…

It turns out that the problem was that my cube was a child of another object. I don’t know how to change the settings so my script works though