Hi. I am taking a tutorial on basic collisions on youtube, and i dont know much about unity. I tried the OnCollisionEnter function. Monodevelop wouldnt even recognize it as a function. I even copied the exact code. What di I do? Here is the Code:
function OnCollisionEnter(){
Debug.Log("Hit Something!");
}
scrip
This code looks fine. Are you sure you pasted it into a Javascrip file and not a C# file? Note that both objects must have a collider, and one of the two objects must have a rigidbody for this function to trigger.
– robertbuYou might have to pass it the Collision class for it to work. So: void OnCollisionEnter(Collision col){} Or in your case (Javascript): function OnCollisionEnter(col : Collision){}
– Josh707Put one into the first person controller and it still wont work.
– ponageinaboxas in a rigidbody. But i didn't enable gravity because then the object freaks out.
– ponageinaboxWhat colliders do you have on the object? If you have more than just one collider (player, rigidbody, physics) that will cause issues
– ForgeStudios