FollowBehavior

@ExperimentalFollowingSubspaceApi
sealed class FollowBehavior


A FollowBehavior controls the motion of content as it is following another target, such as a user's head. Currently the options include "soft", which gradually catches up to the target and "static", which does not continuously follow the target.

Summary

Constants

const Int

The default duration, in milliseconds, for a soft follow animation.

const Int

The minimum allowable duration in milliseconds for a soft follow animation.

Public companion functions

FollowBehavior
Soft(durationMs: @IntRange(from = 100) Int)

Creates a behavior where the content smoothly animates to follow the target's movements, creating a comfortable "soft follow" effect.

Public companion properties

FollowBehavior

The content is placed once based on the target's initial pose and does not follow subsequent movements.

FollowBehavior

The content follows the target as closely as possible.

Protected constructors

Protected properties

Pose

Constants

DEFAULT_SOFT_DURATION_MS

const val DEFAULT_SOFT_DURATION_MS = 1500: Int

The default duration, in milliseconds, for a soft follow animation.

MIN_SOFT_DURATION_MS

const val MIN_SOFT_DURATION_MS = 100: Int

The minimum allowable duration in milliseconds for a soft follow animation.

Public companion functions

Soft

Added in 1.0.0-alpha11
fun Soft(durationMs: @IntRange(from = 100) Int = DEFAULT_SOFT_DURATION_MS): FollowBehavior

Creates a behavior where the content smoothly animates to follow the target's movements, creating a comfortable "soft follow" effect. This is implemented with the Hermite easing algorithm, which accelerates the content then slows it down towards the end of the motion, giving it a sense of real world physics. The use of the Hermite algorithm is not optional but the total duration of the motion can be modified.

Parameters
durationMs: @IntRange(from = 100) Int = DEFAULT_SOFT_DURATION_MS

Amount of milliseconds it takes for the content to catch up to the user. Default is DEFAULT_SOFT_DURATION_MS milliseconds. A value less than MIN_SOFT_DURATION_MS will be rounded up to MIN_SOFT_DURATION_MS to allow enough time to complete the content movement.

Returns
FollowBehavior

A FollowBehavior instance configured for soft following.

Public companion properties

Static

Added in 1.0.0-alpha11
val StaticFollowBehavior

The content is placed once based on the target's initial pose and does not follow subsequent movements.

Tight

Added in 1.0.0-alpha11
val TightFollowBehavior

The content follows the target as closely as possible.

Protected constructors

FollowBehavior

protected FollowBehavior()

Protected properties

targetCurrentPose

Added in 1.0.0-alpha11
protected var targetCurrentPosePose