SOLVED

MRTK Question: How to end a grab interaction via code?

Deleted
Not applicable

I've been searching through the documentation and experimenting with several approaches, but I haven't been able to find an easy way to accomplish this.

 

Say you have a cube with all of the script components attached to allow the user to grab the cube with either hand and move it around (Box Collider, NearInteractionGrabbable, Object Manipulator).

 

How would you go about forcing the user to let go via code? Let's assume you've set a new Vector3 to the transform position on the cube to teleport the cube back to its starting location. How do you properly end the grab?

 

What happens is that after changing the cube's position in code it flys back into the user's pinched fingers like they have Jedi powers :cryingwithlaughter:

 

I've tried two approaches so far to force the hand tracking to just let it go:

 

  1. Disabling the NearInteractionGrabbable and Object Manipulator script components on the cube and then re-enabling them.

  2. Changing the Manipulation Type property on the Object Manipulator to none (0).

 

The problem is, the moment you either re-enable them or set the ManipulationType back to One and Two Handed... Force powers kick in and the cube flys back into your fingers.

 

I'm assuming this is because both the disabling/re-enabling or setting to none/setting back to both hands is occuring within the same frame.

 

So, the next thing I'm going to try is creating an action queue so that the re-enablement step (or setting ManipulationType back to both hands) occurs in the next frame.

 

Any thoughts though? 

 

Is there some simple release() method that I'm overlooking?

1 Reply
best response
Solution
Well... none of that worked.

I think I'll try just destroying the game object and instantiating a new one back in its starting location.
1 best response

Accepted Solutions
best response
Solution
Well... none of that worked.

I think I'll try just destroying the game object and instantiating a new one back in its starting location.

View solution in original post