Search Unity

No Anchor Points after ApplyWorldMap

Discussion in 'AR' started by MaxFroeschl, Mar 18, 2020.

  1. MaxFroeschl

    MaxFroeschl

    Joined:
    Jan 10, 2020
    Posts:
    1
    Hi,

    I've created an anchor in ARAnchorManager with AddAnchor, saved the serialized worldmap into a file and restored it afterwards with ApplyWorldMap. After successfully applying the worldmap to my session ie. stored planes are showing up but I don't see any anchors in ARAnchorManager from my previous session.

    How would I save&restore anchor points between app sessions?

    I'm currently using AR Foundation and ARKit XR Plugin 3.1.0-preview.4.
     
    Last edited: Mar 18, 2020
    yty likes this.
  2. yty

    yty

    Joined:
    Aug 10, 2009
    Posts:
    82
    I have the same problem...

    I am guessing that cloudAnchor may be used,

    but arfoundtion does not support

    Can someone help us? Thanks...
     
    Last edited: May 7, 2020
  3. yty

    yty

    Joined:
    Aug 10, 2009
    Posts:
    82
    I have new clues,
    But it seems to be unavailable in unity3d.

    Restore AR Content After Relocalization
    Saving a world map also archives all anchors currently associated with the AR session. After you successfully run a session from a saved world map, the session contains all anchors previously saved in the map. You can use saved anchors to restore virtual content from a previous session.

    In this app, after relocalizing to a previously saved world map, the virtual object placed in the previous session automatically appears at its saved position. The same ARSCNView delegate method renderer(_:didAdd:for:) fires both when you directly add an anchor to the session and when the session restores anchors from a world map. To determine which saved anchor represents the virtual object, this app uses the ARAnchor name property.

    func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
    guard anchor.name == virtualObjectAnchorName
    else { return }

    // save the reference to the virtual object anchor when the anchor is added from relocalizing
    if virtualObjectAnchor == nil {
    virtualObjectAnchor = anchor
    }
    node.addChildNode(virtualObject)
    }



    In your own AR experience, you can choose among various techniques for restoring virtual content associated with saved anchors. For example:

    • An app for visualizing furniture from a fixed catalog might save an identifier for each placed object in the corresponding anchor’s name, then use that identifier to determine which 3D model to display when resuming a session from a saved map.

    • A game that places virtual characters to play in the user’s environment might create various custom ARAnchor subclasses to store gameplay data specific to each character, so that resuming a session from a saved map also restores the state of the game. (See ARAnchor Subclassing Notes and ARAnchorCopying.)
     
  4. MaximilianFroeschl

    MaximilianFroeschl

    Joined:
    May 7, 2020
    Posts:
    2
    Hi yty,

    in my case it was a lack of understanding of how anchors work.
    My current understanding is now they are either connected to AR planes or points in the AR point cloud and need the corresponding AR managers up and running. In my case points in the AR point cloud.

    So, I solved my issue by letting all relevant AR components enabled at all times. I think it was basically about AR Point Cloud Manager and AR Anchor Manager to stay enabled, but I'm not 100% sure as I restructured the whole app to make this happen. It also seemed to me some AR components are very sensitive to disabling and re-enabling during the app life cycle. So, probably a good idea to disable AR components as less as possible.