0
votes

I am using unityscript and I have no idea why but the OnCollisionEnter Function never calls, even when logging it in unity3d. Is there an alternative or a reason why this is happening?

By the way I am trying to use this collision detection function to find out if the Main Camera is touching a wall or anything.done

This is exactly what I have done:

  1. I created a unityscript file.
  2. I replaced all the contents with just:

    function OnCollisionEnter(theCollision : Collision) {
         Debug.Log("Hit");
    }
    
  3. Now I drag that file, having been saved, to Main Camera.

  4. In the game I move the main camera to a wall or cube object, but it does not Log "Hit".

Thanks

1
Hello you need to share more details about this. You could start by posting the code with your question, then only will anybody will be able to help you. Give us more info about the problem, for example the code. - Tuhin Bhatt

1 Answers

1
votes
  1. First Check If the script is attached to the GameObject.
  2. Then check if there is RigidBody Component attached to a GameObject(on which you are attaching the script with OnCollisionEnter)

Post the code so we can get better idea