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.

Camera position and anchor position issues with Unity across scenes

DanglingNeuronDanglingNeuron ✭✭✭
edited June 2016 in Questions And Answers

[UPDATE] OK I found out how to use WorldAnchorStore and WorldAnchors and now am trying to save/load anchors .. will update the thread whne I am successful.

I am facing a weird issue.

In my first Unity scene the user places a dummy "game arena" using gaze. when he is done, I save the world coordinates (unity transform) and then he selects a level number and I load that level (Each game level will be a separate scene). That level scene has its own actual game arena with game objects on it. I set its position to the coordinates I had saved earlier.

However, it does not appear in the "users selected position from the first scene".

It sort of looks like In each scene, the Unity Camera / HoloLens SDK is resetting its position to absolute zero and its direction to absolute forward (+z axis)

what I mean by that is that if I stand at Point A looking at the front wall of my room during scene 1 and place the arena ... then while teh actual game scene level is loading I move to point B and turn around to look at the back wall of my room.. the arena is placed relative to that instead of at the absolute position.

I also tried to apply "DontDestroyOnLoad" to the main camera in the very first scene and removed the camera prefabs from subsequent scenes .. I was hoping that if the first ever camera is not destroyed.. then the attached "hololens" objects will stay intact and the "reset" wont happen.. but it dint work.

Now I know I may have to change the way I am thinking the scene/level structure and DUMP everything into one scene so things stay in the same place but that is probably not good for big games or games with many levels... I wonder how fragments does it, its probably all a single scene... OR maybe I can use the "merge scene functionality" hmmm.... my game proect is going to take longer than I hoped :)

@neerajwadhwa @HoloSheep

Healthcare IT professional by day - Indie GameDev for UWP and mobile platforms by night

Tagged:

Best Answer

Answers

  • DanglingNeuronDanglingNeuron ✭✭✭
    edited June 2016

    OK, I have resolved this issue using WorldAnchors. It was a little tricky and the documentation is .. well lacking...

    One thing that took me some time to figure out was that if some child objects are static .. they stay in the "initial" design time position, while the rest move to the world anchor - in case anyone else is wondering what the heck is happening with their scene after restoring a world anchor point.

    Healthcare IT professional by day - Indie GameDev for UWP and mobile platforms by night

  • What do you mean by static?

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

  • DanglingNeuronDanglingNeuron ✭✭✭
    edited June 2016

    @Patrick so I am basically trying to place a "parent" gameobject that has some children marked static in unity - full static i.e. lightmapping static, occlusion static etc etc
    Those static children did not move relative to the parent when the world anchor was applied. I had to disable all children in hierarchy and re-enabled them after restoring the world anchor point on the parent GO. That solved the issue and all static children moved / repositioned relative to the parent GO.

    Healthcare IT professional by day - Indie GameDev for UWP and mobile platforms by night

  • okay, I'll see about getting this added to the docs. I haven't messed static objects before. I'm going to spend a little time right now experimenting.

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

  • @Patrick yeh, so basically my parent GO is Arena.. it has static children like arena floor/boundary/walls itself and then mobile units (non static) like tanks. i have marked the floor/boundary/walls static for lightmapping as well as better physics performance for colliders. When world anchor is applied to the parent Arena object, the non-static children moved to the right spot, but the whole arena visual stayed in the initial position.. i was pulling my hair out the whole night, but works like a charm now.

    Healthcare IT professional by day - Indie GameDev for UWP and mobile platforms by night

  • are you still having to do the management of the static objects you described?

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

  • yes.. i will try to create a new sample project and replicate then send it over to you. maybe there is some kind of race condition in my scripts.. but I dont think so.

    Healthcare IT professional by day - Indie GameDev for UWP and mobile platforms by night

  • cool, I'll check it out.

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

Sign In or Register to comment.