6

For SCNNodes we have SCNBillboardConstraint, so is there any way how to apply this constraint to an entity (when working with RealityKit instead of SceneKit) in order the entity always to face the camera as the device is moving?

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
izzym
  • 89
  • 3

1 Answers1

9

Use look(at:from:upVector:relativeTo:) instance method that positions and orients the entity towards a target from a given position.

       func look(at target: SIMD3<Float>, 
             from position: SIMD3<Float>, 
                  upVector: SIMD3<Float> = SIMD3<Float>(0, 1, 0),         
relativeTo referenceEntity: Entity?)

In your code it might look like this:

entity?.look(at: otherEntity!.position, 
           from: entity!.position, 
       upVector: [0, 1, 0], 
     relativeTo: nil)
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220