Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Question Grab-able objects interfering with locomotion system

Discussion in 'XR Interaction Toolkit and Input' started by unity_J2-PAmxzfzl9Dw, Mar 26, 2022.

  1. unity_J2-PAmxzfzl9Dw

    unity_J2-PAmxzfzl9Dw

    Joined:
    Mar 23, 2022
    Posts:
    3
    I posted this in a separate forum before finding this one.
    I have an XR Origin with Character Controller and Capsule Collider so that my rig follows terrain correctly and responds to static object colliders. The problem is, when I pick up a grab-able object, the object's collider interferes with my XR Origin collider and I'm unable to control locomotion using continuous move. It's almost like the object is "pushing" my character around. How do I go about fixing this issue, but still having my XR Origin respect static and terrain colliders?

    Details: XR Origin has components Character Controller and Capsule Collider set at defaults.
    Grab-able object: Rigid Body Mass 1, Use Gravity, Collision Detection Continuous Dynamic.

    Thank you
     
  2. CrAzYpotpie

    CrAzYpotpie

    Joined:
    Sep 24, 2020
    Posts:
    11
    Disable collision between the object and your player's capsule collider when the grabbing takes place. Alternatively, you could just set it up so that the player will never collide with the object to begin with (Edit->Project Settings->Physics->Layer Collision Matrix.)

    Look into this (https://docs.unity3d.com/ScriptReference/Physics.IgnoreCollision.html), or search for more information on collision detection and disabling online.
     
    SmithySFC likes this.
  3. kej-unity

    kej-unity

    Unity Technologies

    Joined:
    Jun 28, 2019
    Posts:
    5
    Hi @unity_J2-PAmxzfzl9Dw

    What @CrAzYpotpie says is right. I posted a longer answer after verifying the
    Physics.IgnoreCollision
    solution in that earlier post you mentioned. We think it can be a useful option to be added on the
    XRGrabInteractable
    to avoid player colliders and will work on that in a future version. Thanks!
     
  4. CrAzYpotpie

    CrAzYpotpie

    Joined:
    Sep 24, 2020
    Posts:
    11
    @kej-unity Please do. I love the XR toolkit, but there are a few features that I really would have expected it to have natively. That one is essential, as 80%+ (surely?) VR projects are going to have a player "controller" that can grab objects while also wanting to collide with said objects when they are not being grabbed.

    Of course, this raises quesitons on how to handle it, because there could be the case that a user grabs a large cube, holds that cube over themself, and lets go. This would have the physics engine try to seperate the objects, or cause other wackiness. Guess it would be nice to have it be a flag/boolean you can toggle on the grabbable to tell it to not collide with the players collider on grab for smaller objects. Grabbing big objects would still cause issues of pushing you, though, if not flagged in this way. Or maybe a system where dropping the large cube on yourself doesn't instantly re-enable collision, until you fully exit it. . .

    VR has been an ongoing challenge in developing ways to overcome these various hurdles. Has been quite the experience.