Contents

direction

A vector that points from the user’s device in the direction of the peer device.

Declaration

var direction: simd_float3? { get }

Mentioned in

Discussion

This property is nil when direction is unavailable, such as when the app runs on Apple Watch.

On iPhone, it’s possible to recieve direction for nearby third-party accessories in sessions that enable isCameraAssistanceEnabled.

Interpret Direction

This property is a Cartesian triplet (x,y,z) in normalized units with a range of [0..1]. Nearby Interaction models direction as a coordinate on a sphere, such that a ray cast from the sphere’s center through the coordinate points toward the peer device. For each axis, the sphere center is at coordinate 0, and the surface is at coordinate 1. As the user looks at the device’s screen,

  • The x-axis extends positively to the right.

  • The y-axis extends positively upward.

  • The z-axis extends negatively from the device’s center, away from the user.

The following figure illustrates the direction-vector coordinate space from two different angles.

[Image]

For more information, see Initiating and maintaining a session.

See Also

Acquiring relative direction