Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

OnTriggerEnter event for CharacterController without Rigidbody. Is it possible?

Discussion in 'Getting Started' started by alexeyterno, Jan 16, 2020.

  1. alexeyterno

    alexeyterno

    Joined:
    May 14, 2019
    Posts:
    10
    I'm using CharacterController to move my character. My character has collider with Trigger tag. Also I have a door with two colliders - one for physic and second with the Trigger tag. With this components I can't get OnTriggerEnter handler when character nigh to the door. If I adding Rigidbody into my door instead triggered collider OnTriggerEnter handler successfull works but my character may "jump" in to second floor when the door is opening and pushing character. How can I get a collider collision for CharacterController and without Rigidbody using?
     
  2. Bill_Martini

    Bill_Martini

    Joined:
    Apr 19, 2016
    Posts:
    445
    I think you have things turned around. First one item of the two must have a Rigidbody for colliders to work. A collider marked as a Trigger will not interact using physics with a Rigidbody object whereas a standard collider will.

    You can solve the problem in several ways; Increase the Trigger collider size as to trip the door animation earlier, prevent the player from moving while door animation is running, or disable the collider on the door while the door is animating. If you are using Unity's CharacterController it already has a collider and you don't need to add your own.
     
  3. alexeyterno

    alexeyterno

    Joined:
    May 14, 2019
    Posts:
    10
    I just solved this issue. I have deleted Rigidbody from door object. For colliders intersection I use Raycast function into Update. I just tested this solution - works as planned. And I have deleted additional collider from character )