Reputation: 67
I'm developing a game in unity using UnityScript. I've initially created two objects, a sphere and a cube, having respective colliders. Now I'm trying to detect a collision between them using the below UnityScript function. But I'm not able to detect collision. I've also added a rigid body component to both of them. How can I detect a collision?
function OnCollisionEnter(col : Collision)
{
if(col.collider.tag=="Cube")
{
Debug.Log("collision");
}
Upvotes: 0
Views: 7903
Reputation: 867
Things to verify:
Also, the rigidbody component only adds physics to the objects and is not necessary when simply detecting collisions.
Upvotes: 2