Search Unity

Question 360 enviroment Unity for Hololens2

Discussion in 'AR' started by Poggy1993, Feb 21, 2023.

  1. Poggy1993

    Poggy1993

    Joined:
    Nov 8, 2022
    Posts:
    7
    Hello everyone,
    I'm trying to create a 360 environment in unity for the Hololens2.
    I found some videos on YouTube where they showed the possibility of creating spheres and using a 360 image as a skybox in Cubemap mode to create the 360-enviroment.
    This method works, but if the sphere is too big it goes beyond the walls of the room, and if it is too small it goes out of perspective as soon as you move. I wanted to know if there is a way for the sphere or the environment to move with the user and not overlap the room but adapt to it so that a completely different environment can be created.
    I hope for an answer from someone more experienced than me, many thanks.
    Regards,

    Simone
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,440
    could use shader that draws on top of everything, if thats the issue for walls blocking view (when user is inside 360 view)
     
  3. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    Make your sphere a child of the Main Camera GameObject within the hierarchy of your AR Session Origin (AR Foundation 4) or XR Origin (AR Foundation 5)
     
  4. Poggy1993

    Poggy1993

    Joined:
    Nov 8, 2022
    Posts:
    7
    I tried to make the sphere a child of the Main camera GameObject in the MixedRealityPlayspace didn't work. Instead of showing the 360 images now the image is fixed on one part only.
    How can I create a shader that draws on top of everything?
     
  5. Poggy1993

    Poggy1993

    Joined:
    Nov 8, 2022
    Posts:
    7
    Unfortunately, did not work, if use the sphere as child object I can see only one part of the sphere and I cannot turn and see the environment, the view in that case is fixed.
     
  6. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    Ah I see. If you want your sphere to move with the user's position but not their rotation, I would try something like

    Code (CSharp):
    1. public Camera mainCamera;
    2.  
    3. void Update()
    4. {
    5.     transform.position = mainCamera.position;
    6. }
    In this setup, your sphere GameObject is at the root of your scene hierarchy, and you attach this component to your sphere. You drag in a reference to your main camera, then every frame your sphere's position will be updated to match the player position. Their rotations will remain independent so the player can look around and see the full dimensions of the sphere.

    Hope that helps!
     
  7. Poggy1993

    Poggy1993

    Joined:
    Nov 8, 2022
    Posts:
    7
    Thank you andyb. Could I ask you how to implement the script, I mean using Unity, can I create the script on the main camera and add the code or how?

    Unfortunately, I'm new with Unity and I'm trying to fix some issues with the HoloLens for research purposes.
     
  8. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    Unfortunately we are not able to provide this level of consultation over the forums. I recommend that you brush up on some Unity basics and return to this problem when you have a stronger understanding of MonoBehaviours. GMTK's latest tutorial seems quite popular as one learning option:
     
    thomas_key likes this.