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

Add new control mode to ManualCameraControl #80

Closed stbertou closed 8 years ago

stbertou commented 8 years ago

Right now the ManualCameraControl script provides a fly mode control which can make it hard to simulate how you would move if you were in a HL experience. This looks like an interesting and useful change that should make it easier to design HL app straight from Unity. I propose to add a new control option so it only allow you move on a X/Z plane and on the Y axis (to simulate squat) An enum would be added so it’s possible to use the current fly mode control (will be the default option) or use the new walk mode control. Any thoughts?

jochao commented 8 years ago

To clarify, would a sufficient solution be something like, "WASD" for movement on x/z plane, and maybe "QE" for up and down movement along y?

stbertou commented 8 years ago

Definitely! I used Page down/up because I usually move the camera using the arrow keys and didn't realise you can also move with WASD either way would work for me One thing annoying using WASD is that you can accidentally try to save when you also press CTRL to move the camera.

I prototyped it, it's quite basic :

        Vector3 deltaPosition = Vector3.zero;
        deltaPosition += GetKeyDir("left", "right") * this.transform.right;
        if (controlMode == ControlMode.Fly)
        {
            deltaPosition += GetKeyDir("down", "up") * this.transform.forward;
        }
        else
        {
            deltaPosition += GetKeyDir("down", "up") * new Vector3(this.transform.forward.x, 0, this.transform.forward.z).normalized;
            deltaPosition += GetKeyDir("page down", "page up") * Vector3.up;
        }
jwittner commented 8 years ago

@stbertou #65 was related to the CTRL + S issue and mostly resolved it by defaulting the keybinding to SHIFT.

NeerajW commented 8 years ago

@stbertou would you like to issue a pull for your updates?

stbertou commented 8 years ago

@jwittner OK I see now why the default was changed to SHIFT @NeerajW sure thing, will do asap

stbertou commented 8 years ago

Hi all please find the code here: https://github.com/Microsoft/HoloToolkit-Unity/pull/83 Note that I've also exposed some hard coded values