# Anchor components

Two Blueprint-spawnable components that bind a scene transform to the AR 51 spatial anchor reported by [`UAnchorServiceComponent`](/docs/sdk-api/unreal-api/classes/uanchorservicecomponent) every frame. **`UCameraAnchorComponent`** pins attached content to the anchor by applying the *inverse* anchor transform; **`UWorldAnchorConstraintComponent`** makes the owning actor *follow* the first registered anchor. Use one or the other depending on whether you want content world-locked relative to the anchor, or an actor that tracks the anchor.

:::caution[Units & space]
Anchor transforms returned by [`UAnchorServiceComponent`](/docs/sdk-api/unreal-api/classes/uanchorservicecomponent) are in **Unreal world space — centimeters and degrees**. AR 51 mocap/CVS data is in meters; if you mix the two, convert with the service's `AR51SDKToWorldSpace` / `WorldToAR51SDKSpace` helpers first.
:::

## UCameraAnchorComponent

<Badge tone="type">UCLASS · USceneComponent</Badge> <Badge>BlueprintSpawnableComponent</Badge>

```cpp
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class AR51SDK_API UCameraAnchorComponent : public USceneComponent
```

**Inherits:** [`USceneComponent`](https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Runtime/Engine/Components/USceneComponent) *(Unreal Engine)*

Pins this scene component to the AR 51 spatial anchor so attached content stays world-locked. Every tick it sets its local-to-world transform to the **inverse** of the current anchor transform (`UAnchorServiceComponent::GetAnchorTransform().Inverse()`), re-expressing the camera/content relative to the anchor. Attach the content you want anchored as children of this component.

### Properties

`EditAnywhere, BlueprintReadWrite`.

<div className="apiPropTable">

| Property | Type | Default | Description |
|---|---|---|---|
| **General** | | | |
| `EnsureHasAuthority` | `bool` | `false` | when `true`, the per-tick anchor update is applied **only** if the owning actor has network authority (`GetOwner()->HasAuthority()`); when `false`, it always applies |

</div>

### Behavior

On each frame (`TickComponent`), the component reads the active anchor transform from [`UAnchorServiceComponent::GetAnchorTransform()`](/docs/sdk-api/unreal-api/classes/uanchorservicecomponent), inverts it, and writes the result onto its own local-to-world transform. The constructor enables per-frame tick.

`EnsureHasAuthority` gates this update for **networked/multiplayer** scenes: leave it `true` so only the authoritative actor drives anchor placement and clients don't fight over it; leave it `false` (default) for single-player or client-local anchoring where every instance should apply the transform.

## UWorldAnchorConstraintComponent

<Badge tone="type">UCLASS · UActorComponent</Badge> <Badge>BlueprintSpawnableComponent</Badge>

```cpp
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class AR51SDK_API UWorldAnchorConstraintComponent : public UActorComponent
```

**Inherits:** [`UActorComponent`](https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Runtime/Engine/UActorComponent) *(Unreal Engine)*

Constrains the owning actor's scene transform to follow the **first** registered world anchor each frame. On `BeginPlay` it ensures the owner has a `USceneComponent` to drive. If no anchor service or no anchors exist, it logs and does nothing that frame.

### Properties

`EditAnywhere, BlueprintReadWrite`.

<div className="apiPropTable">

| Property | Type | Default | Description |
|---|---|---|---|
| **General** | | | |
| `IsInverse` | `bool` | `false` | selects the transform direction applied every frame: `false` = the anchor's regular Local→World transform; `true` = the anchor's inverse World→Local transform |

</div>

### Behavior

On each frame (`TickComponent`), the component reads [`UAnchorServiceComponent::Instance()->GetAnchors()`](/docs/sdk-api/unreal-api/classes/uanchorservicecomponent), takes `anchors[0]`, and writes the chosen transform's **location and rotation** onto its own local transform. `IsInverse` picks regular vs. inverse direction. The constructor enables per-frame tick.

:::caution[Always uses `anchors[0]`]
`UWorldAnchorConstraintComponent` always follows the **first** anchor only — there is no API to select an anchor by id or index. If your scene has more than one anchor and you need to follow a specific one, this component is not the right tool; reach for [`UAnchorServiceComponent::GetAnchorById`](/docs/sdk-api/unreal-api/classes/uanchorservicecomponent) and drive the transform yourself.
:::

## See also

- [`UAnchorServiceComponent`](/docs/sdk-api/unreal-api/classes/uanchorservicecomponent) — the spatial-anchor service that supplies the transforms both components consume
- [Class index](/docs/sdk-api/unreal-api/classes) — all Unreal SDK types
