Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Feature: VRTK_ObjectLerp (lerp an VRTK_InteractableObject on grab). #1433

Open
wildstyle007 opened this issue Aug 17, 2017 · 16 comments
Open

Comments

@wildstyle007
Copy link

wildstyle007 commented Aug 17, 2017

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_ObjectLerp that 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 the VRTK_ObjectLerp.
  • When an object is grabbed by VRTK_InteractGrab this class checks on the grabbing VRTK_InteractableObject to see if there is a valid / configured VRTK_ObjectLerp available, and if the object is set to lerpTransformOnGrab.
  • If the VRTK_InteractableObject is setup to lerp on grab, then rather than complete the grab as normal, the VRTK_InteractGrab method calls back to a new method on the VRTK_InteractableObject that will start the lerp to position, i.e. StartLerpTransformOnGrab.
  • The VRTK_InteractableObject will then call the VRTK_ObjectLerp to start a coroutine for the lerp to position, i.e. DoObjectTranslation.

Not yet done, to be confirmed:

  • Once the DoObjectTranslation method completes, callback / notify the VRTK_InteractableObject that it's done.
  • The VRTK_InteractableObject then calls the VRTK_InteractGrab script to grab the object again. Only this time it will tell the VRTK_InteractGrab somehow 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.
@wildstyle007
Copy link
Author

Got this working last night, should have a PR in this weekend.

@wildstyle007
Copy link
Author

Things to note about current code:

  • If you keep holding the grab past the end of the translation it will drop the object. So will need to figure out the best way to handle this scenario.
  • Have not yet handle the release while a translation is still in progress.

@wildstyle007
Copy link
Author

There is an object lerp setup for testing in the scene for: 005_Controller_BasicObjectGrabbing

@wildstyle007
Copy link
Author

Have this integrated into my project, so have been using it for a few days now while testing other features. Generally it seems to work and pretty consistently.

Do have the issues I already noted above to discuss, plus on the initial grab of the object it's a bit 'wonky' on the transition.. but if you drop and pick up the same object it's smooth thereafter... thinking perhaps I'm missing something there.

Would appreciate your guys input on this one, as it needs some help.

@thestonefox
Copy link
Member

I'll try and take a look at it next week. This week is crazy busy for me :(

@wildstyle007
Copy link
Author

No worries @thestonefox -- thanks for letting me know. I'm in maximum overdrive this week also! :D

@thestonefox
Copy link
Member

I've had like the super briefest of looks over it. I may have another way of doing it that supports all grab types (maybe!)

@jbat100
Copy link

jbat100 commented Sep 1, 2017

Just a quick suggestion, I had this requirement and it felt more natural to perform the lerp during the trigger press (especially with a grabbing avatar hand). So for example if the actual grab happens at trigger axis 1, the lerp occurs smoothly (before the actual grab) from trigger axis 0 to 1. It might be tricky to find a good way to generalise but worth thinking about.

@wildstyle007
Copy link
Author

wildstyle007 commented Sep 1, 2017

Thing is I suppose that any control button could be grabbing.. not necessarily the trigger. The code I've prototyped so far moves the object first, then once it's in position does the actual grab.

@jbat100
Copy link

jbat100 commented Sep 1, 2017

Maybe there could be an auto-selected but configurable pre-grab lerp axis.

@thestonefox
Copy link
Member

that could be time based or controller axis based

@jbat100
Copy link

jbat100 commented Sep 1, 2017

A quick, hacky, non-generic, but functional and simple option (a slightly modified version of VRTK_TrackObjectGrabAttach) with a distance snap threshold and a different maximum velocities before and after snap:

https://gist.github.com/jbat100/ab89a5ad4a00ebde8ac78e85516e3ae4

Obviously a solution which meets all the requirements described above would be way better, but this seemed less risky for now.

@wildstyle007
Copy link
Author

Thanks for the contribution @jbat100 .. food for thought.

@thestonefox -- any additional thoughts on this feature? Would be great to decide the best course of action and get something into the toolkit. I'm looking to update my local VRTK so will just remove these changes if you have another plan.. let me know, thanks!

@thestonefox
Copy link
Member

Sorry for the delay, just time always is against me looking at things :(

@wildstyle007
Copy link
Author

Still open to discuss other approaches to this feature @thestonefox -- let me know, thanks!

@thestonefox
Copy link
Member

I'm still without Dev computer at the moment so hard to work on things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
VRTK
  
To do
Development

No branches or pull requests

3 participants