Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

How to have Rigidbody act as a trigger only when colliding with Character Controller?

Discussion in 'Physics' started by dkstrong, Jul 7, 2018.

  1. dkstrong


    Aug 17, 2013
    I am making a "pickup" item that I want to act in the physics world. E.g. respond to impulses and explosions, bounce around on the ground, etc. However players (CharacterController) can pick these items up.

    If I give the object a "Trigger" collider the character controller can walk over and seamlessly pick it up.

    However when gravity acts upon it it will fall through the floor.

    If I un check the IsTrigger and treat it as a normal collision. Then I have an issue when the character picks the item up, it creates a small stutter in the player's movement as the character is stopped by the rigid body for a frame or two before the item is picked up/destroyed..

    How can I treat the item as a trigger when interacting with a Character Controller, but otherwise be a normal non trigger Rigidbody?
  2. dgoyette


    Jul 1, 2016
    I'd approach this by having a parent object and a child object on two different layers. For each Layer, you can choose which other layers the object collides/interacts with.

    In this case, the parent object would on on a layer named "CollidesWithEverythingButThePlayer", and it would contain the rigidbody. The child object would be an identical collider, but on a "CollidesOnlyWithThePlayer" layer, and it would be a Trigger collider. (Call the actual layer names what you want, but set up their collision settings in the Physics settings.)

    The result will be an object that interacts realistically with everything except the player. The player won't interact with the parent object at all. Instead, they'll interact with the trigger object only.

    Another way is to forget that complexity and just use OnCollisionEnter to trigger your player pickup. There are some downsides (it might slow the player down to run into it, even if you destroy it on the frame the player collects it, and it could hit your player like a cannon ball if it's moving fast enough), so it's up to you.