Search Unity

  1. Unity wants to learn about your experiences working on a Unity project today. We'd like to hear from you via this survey.
    Dismiss Notice
  2. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice
  3. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

Resolved XRGrabInteractible API

Discussion in 'XR Interaction Toolkit and Input' started by freso, Nov 20, 2020.

  1. freso


    Mar 19, 2013
    Looking at the settings in the inspector (and the code) in v0.10.

    Is there a point of having this? When would it be used?
    Also the doc is a bit misleading, as this only forces rigidbody.useGravity on, and not off. I can only see problems with this. (I would have named it forceGravityOnAfterDetach)

    Code (CSharp):
    1. 563: m_Rigidbody.drag = 0f;
    2. 564: m_Rigidbody.angularDrag = 0f;
    You never reset these values after a drop. I would think it to be bad to change the settings of the rigidbody just because it was picked up.

    Some comments on the tooltip docs
    m_Throw(Angular)VelocityScale: The velocity scale used when throwing.
    This comment is basically the variable name. Worthless. Instead explain what it does. How is changing this value affecting the throw?
    This problem exists on many tooltips. Please go through them all and improve them.

    m_TrackPosition: Whether this interactable should track the position of the interactor
    These trackX variables are named weirdly. Should be called Follow. You don't need to change the variable name, but maybe update the tooltip so it says "... should follow the position..."?

    interactionLayerMask: Only interactors with this Layer Mask will interact with this interactable
    Bad wording. Should be "Only interact with interactors which interactionLayerMask matches any layer in this mask".
  2. chris-massie


    Unity Technologies

    Jun 23, 2020
    The use case of using the
    property is pretty narrow. One example would be if you wanted to pin an object in space, but then once you pick it up, have another behavior set that property to true to allow gravity to be enabled on the Rigidbody on drop.

    We're planning on allowing developers to override the section in code where we set values on the Rigidbody upon grab and release so they can modify that functionality easier.

    Your point about the name is a good one. We'll see about the best way to address that since the current name is pretty misleading. We may end up changing it to be an enum dropdown to allow configuring it to either set true, false, or restore the value rather than being a "force gravity on" override. The drag/angularDrag issue you brought up is a bug and we'll get that fixed.

    Regarding the tooltip docs, thanks for your feedback and we'll take another pass through those.
  3. freso


    Mar 19, 2013
    Sorry for late reply, forgot to set watch on thread. I see you fixed a lot of this in pre3. Great!

    If the use-case is this narrow, it probably should not be built-in into the class. Correct me if I'm wrong, but couldn't we just set gravity on with the Select Exited event (in the inspector)? Add self to the event, and set RigidBody.useGravity = true.

    Also I wouldn't over-design these classes with hooks everywhere. I'd rather you built good stable unbloated base classes for advanced developers, and build these simple example usage classes for common folks and easy implementation.

    For example: I don't think "Throw on detach" belongs built-in into the Interactable either. This is another narrow use-case that bloats the class (and inspector). You should just have the expected "inherit velocity from hand".
    If you really want it built-in, add it to a XRInteractablePlusUltra that is a bloated everything-included class.