One Logo Pool Ball
RealityFoundation · IOS API REFERENCE

AnchoringComponent

struct · iOS 13.0+ · SDK 27.1

struct AnchoringComponent

A component that anchors virtual content to a real world target. This component is essential for getting AR features into RealityKit. Use `AnchoringComponent` to anchor virtual content to a real world target by attaching the component to any ``Entity`` in your RealityKit scene. To create an `AnchoringComponent`, you need to specify a ``AnchoringComponent/Target-swift.enum``. You can also specify the ``AnchoringComponent/TrackingMode-swift.struct`` and the ``AnchoringComponent/PhysicsSimulation-swift.enum`` to control how the entity tracks the anchor and how the physics simulates with the entity. For example, here's how to create an entity that targets the left hand's wrist with predicted tracking mode: ```swift let target = AnchoringComponent.Target.hand(.left, location: .wrist) let anchoringComponent = AnchoringComponent(target, trackingMode: .predicted) let entity = Entity() entity.components.set(anchoringComponent) ``` The entity with `AnchoringComponent` is inactive when created. RealityKit anchors and activates the entity when it finds an anchor that meets the target requirements. You can check the entity's anchored status using ``Entity/isAnchored``, or you can subscribe to ``SceneEvents/AnchoredStateChanged`` events to receive scene events. Similarly, RealityKit unanchors the entity if the target disappears or no longer meets the target requirements. For more information about anchors, see <doc://com.apple.documentation/documentation/arkit>.

Members (8)

get · iOS 18.0+

trackingMode

TypeScript
get trackingMode(): AnchoringComponent_TrackingMode
Swift declaration
var trackingMode: AnchoringComponent.TrackingMode { get set }

Defines how the `Entity` tracks its target anchor.

set · iOS 18.0+

trackingMode

TypeScript
set trackingMode(value: AnchoringComponent_TrackingMode)
Swift declaration
var trackingMode: AnchoringComponent.TrackingMode { get set }

Defines how the `Entity` tracks its target anchor.

get · iOS 18.0+

physicsSimulation

TypeScript
get physicsSimulation(): AnchoringComponent_PhysicsSimulation
Swift declaration
var physicsSimulation: AnchoringComponent.PhysicsSimulation { get set }

Specifies the physics simulation spece that the entity and its descendants are in.

set · iOS 18.0+

physicsSimulation

TypeScript
set physicsSimulation(value: AnchoringComponent_PhysicsSimulation)
Swift declaration
var physicsSimulation: AnchoringComponent.PhysicsSimulation { get set }

Specifies the physics simulation spece that the entity and its descendants are in.

get · iOS 13.0+

target

TypeScript
get target(): AnchoringComponent_Target
Swift declaration
let target: AnchoringComponent.Target

The real world anchor target to attach the entity to.

init · iOS 18.0+

init

TypeScript
static initTrackingModePhysicsSimulation(target: AnchoringComponent_Target, trackingMode: AnchoringComponent_TrackingMode, physicsSimulation?: AnchoringComponent_PhysicsSimulation): AnchoringComponent
Swift declaration
init(_ target: AnchoringComponent.Target, trackingMode: AnchoringComponent.TrackingMode, physicsSimulation: AnchoringComponent.PhysicsSimulation = .isolated)

Creates an anchoring component for a given target, tracking mode and physics simulation. - Parameters: - target: The kind of real world object to target. - trackingMode: The tracking mode of the entity. - physicsSimulation: The physics simulation space the entity will be in.

init · iOS 18.0+

init

TypeScript
static initTrackingMode(target: AnchoringComponent_Target, trackingMode: AnchoringComponent_TrackingMode): AnchoringComponent
Swift declaration
init(_ target: AnchoringComponent.Target, trackingMode: AnchoringComponent.TrackingMode)
init · iOS 13.0+

init

TypeScript
static init(target: AnchoringComponent_Target): AnchoringComponent
Swift declaration
init(_ target: AnchoringComponent.Target)

Creates an anchoring component for a given target. - Parameters: - target: The kind of real world object to target.

Skipped declarations

No declarations were skipped in this snapshot.

All RealityFoundation types →