Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

OnCollision Enter doesn't work

Discussion in 'Scripting' started by justadeveloper, Apr 5, 2015.

  1. justadeveloper

    justadeveloper

    Joined:
    Jan 12, 2014
    Posts:
    33
    I have a character controller with a rigidbody and a terrain with a terrain collider, but when I let my character fell down use gravity and touched the terrain, OnCollisionEnter can't Debug.Log("Test").How to fix this one?
     
  2. maleone0487

    maleone0487

    Joined:
    Feb 23, 2011
    Posts:
    59
  3. justadeveloper

    justadeveloper

    Joined:
    Jan 12, 2014
    Posts:
    33
  4. justadeveloper

    justadeveloper

    Joined:
    Jan 12, 2014
    Posts:
    33
    dude,I got a new problem,I just realized that when an object collide with other object using that script,It's always colliding again and again(means that it doesn't work like an OnCollisionEnter,more likely work as an OnCollisionStay).....
     
  5. maleone0487

    maleone0487

    Joined:
    Feb 23, 2011
    Posts:
    59
    You'll most likely have to manage this yourself. For example set a flag to true when the object is grounded and check against that state on each hit event to poll for changes. If you search around there should be a few examples to help you out.