Search Unity

ARFoundation ApplyWorldMap - MakeContentAppearAt Issue

Discussion in 'AR' started by JoeGrainger, Jan 21, 2019.

  1. JoeGrainger

    JoeGrainger

    Joined:
    Oct 20, 2012
    Posts:
    19
    Hey,

    I'm currently trying to align an object correctly on two separate devices.

    I've got both devices networked, the client device successfully downloads and applies the uploaded WorldMap - everything lines up perfectly, I am using an ARReferencePoint to share the position of the 'placement object' I am lining up.

    I attempt to 'MakeContentAppearAt' on both devices when the setup phase of the AR session is complete. At this point for whatever reason I cannot get the same behaviour on both even though they are calling the same code, and printing out whilst running the session on each device tells me they are both using the same ARReferencePoint.Transform for 'MakeContentAppearAt'.

    Here is the code that runs on both host and client devices once the AR WorldMap has been successfully applied

    Code (CSharp):
    1.  
    2. // position the content
    3. sessionManager.sessionOrigin.MakeContentAppearAt
    4. (
    5.     map.transform,
    6.     mapARReferencePoint.transform.position,
    7.     mapARReferencePoint.transform.rotation
    8. );
    9.  
    10. // scale world data
    11. sessionManager.sessionOrigin.transform.localScale = Vector3.one * scaleFactor;
    12.  
    Any help or suggestions would be greatly appreciated!

    Thanks,
    Joe
     
    euphonic likes this.
  2. JoeGrainger

    JoeGrainger

    Joined:
    Oct 20, 2012
    Posts:
    19
    So I’ve finally figured it out. I originally assumed the root problem was related to the scaling of the content via MakeContentAppearAt() - this is not the case.

    I wrote my own scaler code to make double sure and this was also not aligning correctly, it would be the wrong position, rotation or it would drift over a period of time.

    Shortly after the scale code is executed I disable the ARPlaneManager ( as I no longer need it to cast against in the scene )

    If you disable the ARPlaneManager - any ARReferencePoint objects will lose their anchoring and begin to drift, change position or rotation.

    It turns out they are linked together although I hadn’t found this mentioned in the documentation and so it was a single line of code I blindly ignored. I assumed a reference point would calculate its position based off known points surrounding it rather than be tethered directly to a plane?

    Anyway hopefully this helps someone!
     
    FlolF, bleed_123 and euphonic like this.