-
-
Notifications
You must be signed in to change notification settings - Fork 984
Open
Labels
Description
Overview
General idea is to add new functionality that smoothly animates an object into position when you grab it. This will be an optional / extra script that you can attach to an VRTK_InteractableObject, providing a slightly different mechanic and visual from the existing immediate grab.
Code In-progress
- Created a new script class called
VRTK_ObjectLerpthat smoothly handles the lerp position and rotation of an object over time. - You can attach this script to an
VRTK_InteractableObject, which then will set itself up to use theVRTK_ObjectLerp. - When an object is grabbed by
VRTK_InteractGrabthis class checks on the grabbingVRTK_InteractableObjectto see if there is a valid / configuredVRTK_ObjectLerpavailable, and if the object is set tolerpTransformOnGrab. - If the
VRTK_InteractableObjectis setup to lerp on grab, then rather than complete the grab as normal, theVRTK_InteractGrabmethod calls back to a new method on theVRTK_InteractableObjectthat will start the lerp to position, i.e.StartLerpTransformOnGrab. - The
VRTK_InteractableObjectwill then call theVRTK_ObjectLerpto start a coroutine for the lerp to position, i.e.DoObjectTranslation.
Not yet done, to be confirmed:
- Once the
DoObjectTranslationmethod completes, callback / notify theVRTK_InteractableObjectthat it's done. - The
VRTK_InteractableObjectthen calls theVRTK_InteractGrabscript to grab the object again. Only this time it will tell theVRTK_InteractGrabsomehow that we don't need to lerp, just do a normal / immediate grab.
Other things to consider, as per our chat on Slack:
- What to do if the object is ungrabbed mid-way, before completion:
: Move the object back to the start position.
: Or if it's pass the half way point complete the lerp.
: Or just drop the object where it is.
: Perhaps a combination, could have settings to specificy what you want to happen. - From @bddckr: "Should work with every grab mechanic, but I think currently some of these things take at least 1 frame, so would be visible. Maybe instantiate a temporary copy and turn of visibility and collisions etc.":
: Not sure I understand what this is referencing yet.. perhaps I'll see this issue once the base code I've explained above is working.
thestonefox, bddckr and jbat100