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

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:
    31
    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?
     
    zerocalll likes this.
  3. SecondCobra

    SecondCobra

    Joined:
    Jan 25, 2017
    Posts:
    31
    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
     
  6. faultanxiety

    faultanxiety

    Joined:
    Jul 14, 2023
    Posts:
    2
    Thanks for the explanation, I was looking for it too.