Skip to content

Animations

Max Cobb edited this page Sep 5, 2022 · 6 revisions

Add these animations to your RealityKit entities for a smoother looking Augmented Reality environment.

Spin

With RealityKit, the entities will always rotate along the shortest path to the end orientation, but that means any it will never rotate beyond 180º on its own. For example, if an entity is instructed to turn by 359º clockwise, it will instead turn 1º anti-clockwise (or counter-clockwise if you rather). Entity.ruiSpin allows you to spin an object for as long as you like.

See the documentation here.

External extensions not yet supported by DocC

Example

myModel.ruiSpin(by: [0, 1, 0], period: 1, times: 2)

Shake

Subtle but important for UX, you can animate a shake or nudge an entity with Entity.ruiShake. Useful for signalling something wants attention (like an incoming call or message), or in an Augmented Reality game if something isn't done right this feature could signal that.

See the documentation here.

External extensions not yet supported by DocC

Example

myModel.ruiShake(by: simd_quatf(angle: .pi / 8, axis: [0, 1, 0]), period: 1, times: 6)
Clone this wiki locally