microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

Controllers shown at original place after teleporting in VR. #5423

Closed rahsingh-ms closed 5 years ago

rahsingh-ms commented 5 years ago

Describe the bug

We are using the WindowsMixedRealityControllers for our App's VR version and when we attempt to teleport in our app, We can see camera hands at the original position.

To reproduce

Steps to reproduce the behavior:

  1. Open VR app on Windows
  2. Try teleporting/moving the main camera to some other location
  3. We can see controllers left behind at original position.

Describe the solution:

This issue is happening because of an error in WindowsMixedRealityController.cs class. In the function private async void CreateControllerModelFromPlatformSDK(uint interactionSourceId)

when the GLTF is found from platfor, while creating the gameobject for controller visualization, we are not adding it to under MixedRealityPlayspace but it is getting added directly to root scene which is causing the issue of seeing controllers at original position after teleportation.

image

The fix is in the BaseController.cs file. In the function: protected virtual bool TryRenderControllerModel(Type controllerType, InputSourceType inputSourceType)

we add MixedRealityPlayspace.AddChild(controllerObject.transform);

This line should actually be moved inside TryAddControllerModelToSceneHierarchy function

so that even if we use the platform controller visualization, they will be correctly added to under MixedRealityPlaySpace game object.

Your Setup (please complete the following information)

issue on mrtk_development branch

Target Platform (please complete the following information)

keveleigh commented 5 years ago

Huh, this was something I noticed and thought I had fixed as part of https://github.com/microsoft/MixedRealityToolkit-Unity/pull/4707. The pointer and grip poses were being properly transformed based on the transform of the playspace, but the source pose wasn't. I'll take a look.

keveleigh commented 5 years ago

Actually, should have been fixed via https://github.com/microsoft/MixedRealityToolkit-Unity/pull/5250

rahsingh-ms commented 5 years ago

Hi, you are right . But the problem here that for specific case of WMR controllers, in the CreateControllerModelFromPlatformSDK() function of WindowsMixedRealityController.cs file, if we get the fileStream for controller from platform, in that case, erroneously the Visualization gameobject is getting added to the scene and not under the MixedRealityPlaySpace gameobject and that is why the teleportation is not working.