Class

FollowBehavior

A FollowBehavior controls the motion of content as it is following another target, such as a user's head.

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free
Android
@ExperimentalFollowingSubspaceApi
public sealed class FollowBehavior protected constructor()

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.

Companion Object

Properties

Android
public const val DEFAULT_SOFT_DURATION_MS: Int

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

Android
public const val MIN_SOFT_DURATION_MS: Int

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

Android
public val Static: FollowBehavior

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

Android
public val Tight: FollowBehavior

The content follows the target as closely as possible.

Methods

Soft

Android
public fun Soft(
            @IntRange(from = MIN_SOFT_DURATION_MS.toLong())
            durationMs: 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 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

A FollowBehavior instance configured for soft following.