Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  3. Read here for Unity's latest plans on OpenXR.
    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:
    644
    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
     
unityunity