createAnchorOrNull

fun HitResult.createAnchorOrNull(): Anchor?

Creates a new anchor at the hit location.

See HitResult.getHitPose for details.

Anchors incur ongoing processing overhead within ARCore. To release unneeded anchors use Anchor.detach.

This method is a convenience alias for hitResult.getTrackable().createAnchor(hitResult.getHitPose())

Return

null if an exception was thrown during anchor creation.


fun Trackable.createAnchorOrNull(pose: Pose): Anchor?

Creates an anchor that is attached to this trackable, using the given initial pose in the world coordinate space. The type of trackable will determine the semantics of attachment and how the anchor's pose will be updated to maintain this relationship. Note that the relative offset between the pose of multiple anchors attached to a trackable may adjust slightly over time as ARCore updates its model of the world.

Return

null if an exception was thrown during anchor creation.