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

Question Can Snapped Objects Ease Into their Socket Instead of Jumping?

Discussion in 'XR Interaction Toolkit and Input' started by MrSuter, Sep 17, 2021.

  1. MrSuter

    MrSuter

    Joined:
    Sep 17, 2021
    Posts:
    2
    Instead of the object "jumping" into position, I want the object to float smoothly into the correct position, rotation, etc. in the socket.

    I don't see a setting for this in the Socket Interactor, maybe there's a script that could do it?

    Thanks for any help!
     
  2. tenconmar

    tenconmar

    Joined:
    Mar 15, 2021
    Posts:
    29
    Using an override method in a separate script that inherits from the XR Socket Interactor would work. It may also be possible to just create your own socket script that set a lerp transform position of object to the socket.
     
    markasuter likes this.
  3. AvinashB9

    AvinashB9

    Joined:
    Feb 10, 2021
    Posts:
    14
    @MrSuter You will find the lerping script in UpdateTarget from XRGrabInteractable. You can copy paste the entire XRGrabInteractable script into new script. Then change the UpdateTarget as per your expectations.
     
  4. FarmerInATechStack

    FarmerInATechStack

    Joined:
    Dec 28, 2020
    Posts:
    57
    Last edited: Sep 2, 2023
  5. FarmerInATechStack

    FarmerInATechStack

    Joined:
    Dec 28, 2020
    Posts:
    57
    I posted a code sample there too in case it helps anyone exploring this. A notable difference though is that I'm not using this with a socket. I'm just trying to return an object to the state of an initial transform.