Hello everyone.

We have decided to phase out the Mixed Reality Forums over the next few months in favor of other ways to connect with us.

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.

The plan between now and the beginning of May is to clean up old, unanswered questions that are no longer relevant. The forums will remain open and usable.

On May 1st we will be locking the forums to new posts and replies. They will remain available for another three months for the purposes of searching them, and then they will be closed altogether on August 1st.

So, where does that leave our awesome community to ask questions? Well, there are a few places we want to engage with you. 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. 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
    Accepted Answer

    Thanks for the input.

Sign In or Register to comment.