Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

Moving the Camera Along a Ray

Hi,
I am looking for a way to move around an extremely large hologram. This hologram is about 200ft by 100ft. In order for me to not have to go into a warehouse or outside to view all of it I would like to have the following happen:
1) be able to look at a part of the hologram at a distance with the cursor
2) have the cursor hit the holograms mesh then,
3) when I say the command keyword "Forward" the camera moves to that location and stops.

If anyone has any ideas of how to get this done properly please let me know. I do know how to deal with setting up speech input source and handlers.
This is the current c# code that I have based off of referenced material.

using UnityEngine;
using System.Collections;

public class ExampleScript : MonoBehaviour {
public bool zooming;
public float zoomSpeed;
public Camera camera;

void Update() {
    if (zooming) {
        Ray ray = camera.ScreenPointToRay(Input.mousePosition);
        float zoomDistance = zoomSpeed * Input.GetAxis("Vertical") * Time.deltaTime;
        camera.transform.Translate(ray.direction * zoomDistance, Space.World);
    }
}

}

Please help. Thank you!

Best Answer

Answers

  • You can't really move the camera in script, because the HoloLens is the camera. You could probably look at the object and then manipulate that object but, moving the camera is generally frowned upon for the HoloLens.

    AR Developer

  • Thanks. How about moving the whole parent gameobject toward the camera then?

  • You could do a Lerp function from its current position to somewhere near the camera's position.

    parent.transform.position = Vector3.Lerp(parent.transform.position, camera.main.transform.position, .5f);

    The third parameter controls where along the line between the two positions that you will be at. Some people put lerps in either an Update function or put it in a loop to go from 0 - 1 (point 1 to point 2) but, in this case you could put it at a certain distance between the two.

    https://docs.unity3d.com/ScriptReference/Vector3.Lerp.html

    AR Developer

  • holonutholonut
    Answer ✓

    Thanks for the input.

Sign In or Register to comment.