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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Question Avoid the reset of rigidbody values after letting go of an object

Discussion in 'XR Interaction Toolkit and Input' started by Jannelt, Feb 11, 2021.

  1. Jannelt

    Jannelt

    Joined:
    Dec 27, 2016
    Posts:
    2
    Hello,
    i'm currently struggling with my own SnapDropZone script, because objects inside of it are kinematic and should be resetted to non-kinematic after taking them out of it. I'm doing that by changing the rigidbody settings when leaving the collider of the snapdropzone. The problem is that the Interaction Toolkit is restoring the values the Gameobject had inside of the snapdropzone after dropping it, ignoring the changes i made while carrying it. I also tried to reset the values in the "Select Exited" event but it seems that this event is executed before the values are resetted. Is there any way to bypass the reset? Changing the code of the interaction toolkit is not possible because of work restrictions.
     
  2. chris-massie

    chris-massie

    Unity Technologies

    Joined:
    Jun 23, 2020
    Posts:
    220
    You can derive from
    XRGrabInteractable
    and override the
    SetupRigidbodyDrop
    method if you would like to change the behavior of it restoring the Rigidbody values to the values that were set on Grab. You should also be able to add a listener to the Select Exited event and override the Rigidbody properties as the Grab Interactable will have already restored the values before the event is invoked.

    We will look into allowing for this behavior to be configured in the Inspector to allow users to set whether the Rigidbody properties will be modified upon grab/drop.
     
  3. Jannelt

    Jannelt

    Joined:
    Dec 27, 2016
    Posts:
    2
    Thanks for the help, i used the listener and it works! Still looking forward to the inspector option.