Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Losing Plane Tracking after Scaling Mars Session Object

Discussion in 'Unity MARS' started by nouse20, Feb 11, 2021.

  1. nouse20

    nouse20

    Joined:
    Oct 6, 2017
    Posts:
    8
    Hi Mars team!

    I have a situation where I need to display large objects in AR. I need to support indoor experiences so I'm building a "Mini Mode" where I'm scaling up the Mars Session object in order to make the digital content smaller, allowing users to view the content on a countertop or table.

    The scaling is working but I notice when I scale the session up, the rays coming from the camera are no longer long enough to detect planes and I am losing plane tracking as a result.

    Is there a way to adjust the ray length during runtime when in this state so the system will continue to detect planes?

    Because I'm using physics, i need to use the world scale method so adjusting the scale of the content itself is not an option. Thanks.

     
  2. mtschoen

    mtschoen

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    194
    Hi there! Sorry you're having trouble.

    It sounds like we need to take world scale into account in this case, and make the rays longer, but that may not be the whole story. Just so I fully understand your use case, what scale value are you using? Are you looking at the raycasts using debug visuals and seeing that they're too short?

    I did a quick test on my end but wasn't able to replicate the issue. I created a new scene, added a MARS Plane Visualizer to it, and cranked the World Scale slider up to a few different values between 100 and 1000. I tried a couple of different environments, and got the expected results: the rays reached the furniture eve though it was >100 units from the camera.

    It is possible to override the raycast length by specifying your own Simulated Discovery Provider prefab using a custom Simulated Discovery Island. The easiest way to do this is to copy the existing prefab and Functionality Island assets out of the package cache and into your Assets folder. We already create a folder for functionality islands under `Assets/MARS/Settings/Functionality Islands`, and I recommend you put the copy there.

    Copying files from a package is a little tricky, because you have to navigate to the files and copy them outside of Unity; the Editor doesn't provide a quick and easy way to duplicate a package asset with a new GUID.

    In this case, you can do what you need with the following steps:
    1. Go to `Project Settings > MARS > Simulation`
    2. Expand the `Advanced` foldout under the `Scene Module` category
    3. Single-click the `Simulated Discovery Island` to ping the asset in the Project view
    4. Right-click the `Simulated Discovery Island` asset and choose `Show in Explorer` or `Reveal in Finder` (depending on your OS)
    5. Copy that file into your assets folder somewhere. Do not drag it in as this will move the file, which we don't want.
    6. Now you should still have the `Simulated Discovery Island` in the package, and one in Assets that you can modify. Feel free to rename this if you want.
    7. Drag the new Functionality Island into the `Simulated Discovery Island` field in the Project Settings window that you originally used to find the one in the package, replacing the existing reference with a reference to the new asset.
    8. Follow the same process for the `Simulated Discovery Provider` prefab; it is referenced under the `Default Providers` foldout in 3 places.
    9. Copy the Simulated Discovery Provider prefab into Assets and replace the references to the old prefab in the new Functionality Island you made.
    10. Modify the `Max Hit Distance` property on that prefab, and restart simulation to see the effect.
    It's a bit complex, but this should allow you to work around and iterate on settings for the Simulated Discovery provider.

    Hope this helps!
     
  3. nouse20

    nouse20

    Joined:
    Oct 6, 2017
    Posts:
    8
    Thank you! this is very helpful and I'll report back if I run into any issues.

    Just to clarify some things. I'm adjusting the scale during runtime, swapping back and forth based on the size of the found plane (which I can do easily now thanks to MARS!)

    Yes, I am using the debug visuals to see they're too short. I'm scaling the Mars Session object to 8 for "mini mode" and back to 1 for default. I also noticed during runtime I need to find the environment object and scale that as well to achieve the correct effect in the editor/simulation environment.

    Please let me know if any of this information changes your instructions on changing the Max Hit distance, or if I need to be doing anything differently. I think as long as i can modify the "max hit distance" property back and forth at runtime, it will be just what I need.

    Thanks again
     
  4. mtschoen

    mtschoen

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    194
    Aha. We may need to make a fix in order to account for changes at runtime. For now, I think you'll just need to tweak these parameters in the prefab. You may be able to set up a runtime override for this provider in the simulation island, but it sounds like you actually want to modify the max distance via script. We don't expose these settings to scripting changes, but we will consider adding public properties to get/set these values so that you can script changes to them for this purpose.
     
  5. nouse20

    nouse20

    Joined:
    Oct 6, 2017
    Posts:
    8
    Sounds good. Thanks for your help!
     
  6. nouse20

    nouse20

    Joined:
    Oct 6, 2017
    Posts:
    8
    Ok finally getting around to trying this and it seems the older "default" prefab with max distance of 2 is still being used when entering play mode. I've attached several screenshots to show how I've set this up according to your instructions. I'm probably missing something but not exactly sure what.
     

    Attached Files:

  7. mtschoen

    mtschoen

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    194
    Close, but not quite! :)

    It took me a few tries to spot it myself, but you're highlighting the `Query Simulation Module` settings there, not the `Scene Module`. There is another pair of object fields below with the same name under `Scene Module` > `Advanced` which you need to set for Play Mode. I'll admit, this is a bit confusing, so it's an easy mistake to make!

    Basically we separate the configuration for what happens in the Simulation View with what happens when you want to simulate in Play Mode. This way, if you want Play Mode to act differently, for whatever reason, you don't have to mess with what happens in Sim View.

    You should see the results you are looking for if you set the Funcitonality Islands in the `Scene Module` section below. Let me know if it works! Good luck!
     
  8. nouse20

    nouse20

    Joined:
    Oct 6, 2017
    Posts:
    8
    Got it! thanks so much for your help and the quick support. I appreciate it.
     
    jmunozarUTech likes this.