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. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Object with gravity and isTrigger

Discussion in 'AR/VR (XR) Discussion' started by SecondCobra, Mar 11, 2017.

  1. SecondCobra

    SecondCobra

    Joined:
    Jan 25, 2017
    Posts:
    26
    Scenario: I have an object on a table, say a screwdriver, that I want the user to be able to pick up so it needs isTrigger on its collider. However this means the object falls through the table when Use Gravity is turned on. This seems like a catch-22 - I need isTrigger on to grab it but I need it to have gravity on so I can't!

    I've seen this done in games so it's possible but I can't figure it out. Summary, I want to be able to pick up an item using the controller and be able to release it so the object falls to the table / floor.

    I have found any number of similar questions when searching, but none actually give an answer (they suggest things such as creating a parent empty Gameobject with a collider but this doesn't seem to work).
     
  2. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    Does it work to make a child with the trigger? Or child with the Rigidbody/Collider and parent with the trigger? Doesn't work to add 2 Colliders and set one as trigger?
     
  3. SecondCobra

    SecondCobra

    Joined:
    Jan 25, 2017
    Posts:
    26
    Thankyou Selzier, this is the simplest explanation I have seen of this. The last point works, simply adding a second collider with isTrigger = true allows the script to trigger without the object falling through items.
     
  4. Dragon_Warrior_007

    Dragon_Warrior_007

    Joined:
    Oct 3, 2020
    Posts:
    1
    thanks so much guys i really needed that
     
  5. modzincltd

    modzincltd

    Joined:
    Dec 20, 2022
    Posts:
    1
    Yes well done I been stiuck on this as well. Dont know why this issue exists though doesnt make sense