Using MRTK V2 and c# scripting, I need to grab and move an object (say a cube) around the camera, at the same distance as it was grabbed and with the cube facing the camera initially to remain perpendicular to the camera. I don't know if I'm clear...
I have not found some "grab" example is the MRTK v2 as there was in the original MRTK, so I'm wondering how to program this actually. I want to affect the transform of the object, not only use the "interactable" script.
I've been able to read the transform of the controller at the beginning and the end of the movement, but I'm wondering how to affect the transform of the target object so it remains at a fixed distance from the controller and stays perpendicular to the controller (face selected still facing the camera).
I've tried affecting the transform of the target object and looking for the right calculation, but without success.
Any idea where I could start looking?
You can add a ManipulationHandler to the object you want to move. Here are some sample steps:
Here is an example configuration that I have to make a cube movable:
For an example of how a ManipulationHandler is used, see the Lunar Module or Cheese objects in the HandInteractionExamples scene at Assets\MixedRealityToolkit.Examples\Demos\HandTracking\Scenes\HandInteractionExamples.unity