Hey Guys,
I am trying to detect a collision with a sphere collider in my game, but am having a difficult time finding information on it. What I have is : A cylinder with an added “Sphere Collider” Component (added through the gui “Add component”). A block called “Unit” which is going to be colliding with the sphere collider. I am trying to make the sphere collider attached to the cylinder print a message when the block enters the collider field. I looked at the documentation and dont know what to do with the code:
public class Tower : MonoBehaviour
{
// Update is called once per frame
void Update ()
{
}
void OnCollisionEnter(Collision col) {
if(col.gameObject.name=="Unit"){
Debug.Log(col.gameObject.name);
}
}
}
Anything would help guys. Thanks,