# Failed to track anchor, but unsure why

**URL:** <https://community.nianticspatial.com/t/failed-to-track-anchor-but-unsure-why/3876>\
**Category:** I'm Stuck\
**Created:** [September 26, 2023, 11:38am UTC](https://community.nianticspatial.com/t/failed-to-track-anchor-but-unsure-why/3876 "2023-09-26T11:38:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Merijn\_Kersten](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/merijn_kersten/32/1277_2.png) [@Merijn\_Kersten](https://community.nianticspatial.com/u/Merijn_Kersten)\
**Post date:** [September 26, 2023, 11:38am UTC](https://community.nianticspatial.com/t/failed-to-track-anchor-but-unsure-why/3876/1 "2023-09-26T11:38:30Z")

</div>

- **ARDK version** : 3.0 (beta 4)
- **Unity version** : 2021.3.27

Description of the issue:  
I’m trying to implement ARLocations into my project, this works fine in editor but when trying to build and run it i get an immediate error saying: Failed to track anchor. Without any further info as to why it would fail here.

As a reference here is the script i’m trying out:

```auto
private void CheckForStateChanged(PlayerState state)
        {
            if (state == PlayerState.Localizing)
            {
                // if vps is already tracking some other location then stop tracking it
                if (_vpsModel.IsTracking)
                {
                    _vpsModel.ARLocationManager.StopTracking();
                    _vpsModel.IsTracking = false;
                }
                
                // find out which location we want to start tracking based on the stored payload data associated with it
                var targetPayload = _waypointModel.SelectedWaypoint.payloadId;
                var locationPrefab = _vpsModel.Locations.Single(item => item.Payload.ToBase64() == targetPayload);
                // create an instance since the transform will be changed (which is not allowed in a prefab)
                _vpsModel.InstancedLocation = Instantiate(locationPrefab);
                // set ar locations to only this new location
                _vpsModel.ARLocationManager.SetARLocations(_vpsModel.InstancedLocation);
                // and start tracking, here i get an immediate failure message without further details
                _vpsModel.ARLocationManager.StartTracking();
                _vpsModel.IsTracking = true;
            }
            else if (state != PlayerState.Localized)
            {
                if (_vpsModel.IsTracking)
                {
                    _vpsModel.ARLocationManager.StopTracking();
                    _vpsModel.IsTracking = false;
                    gameObject.Destroy(_vpsModel.InstancedLocation);
                }
            }

```

If anyone has experience with this or sees what’s wrong in my code please let me know. Also an example scene for this feature would probably help developers to get to grips with it a bit faster.

---

<div class="post-metadata">

**Author:** ![Merijn\_Kersten](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/merijn_kersten/32/1277_2.png) [@Merijn\_Kersten](https://community.nianticspatial.com/u/Merijn_Kersten)\
**Post date:** [September 26, 2023, 12:07pm UTC](https://community.nianticspatial.com/t/failed-to-track-anchor-but-unsure-why/3876/2 "2023-09-26T12:07:21Z")

</div>

After looking into this a bit more i found the issue:  
The persistent anchors toggle wasn’t enabled

It seems obvious now but as a tip i’d add this step to the tutorials/how-to’s on the ARDK 3.0 documentation.

---

<div class="post-metadata">

**Author:** ![Stacy](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@Stacy](https://community.nianticspatial.com/u/Stacy)\
**Post date:** [September 26, 2023, 8:22pm UTC](https://community.nianticspatial.com/t/failed-to-track-anchor-but-unsure-why/3876/3 "2023-09-26T20:22:23Z")

</div>

Hello Merijn,

Thank you for your feedback!  
I have passed along your suggestion to the team to update the documentation to prevent any future issues with the Persistent Anchors setting. Thank you for pointing that out!

As a note, we have removed your screenshot to keep your API key private.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/system/32/13_2.png) [@system](https://community.nianticspatial.com/u/system)\
**Post date:** [October 2, 2023, 11:34am UTC](https://community.nianticspatial.com/t/failed-to-track-anchor-but-unsure-why/3876/4 "2023-10-02T11:34:28Z")

</div>

Closed on October 2, 2023, 11:34am UTC

This topic was automatically closed 2 hours after the last reply. New replies are no longer allowed.
