USDZ Animations with RealityKit 2

init(_ path: String)
  {
    super.init()
     
    self.name = "modelEy"
     
    var cancellable: AnyCancellable? = nil
    cancellable = Entity.loadAsync(contentsOf: URL(fileURLWithPath: path))
      .sink(receiveCompletion: { error in
         
        DispatchQueue.main.async {
          cancellable?.cancel()
          cancellable = nil
        }
      }, receiveValue: { [weak self] ey in
        guard let `self` = self else { return }
         
        ey.name = "animationEy"
        self.addChild(ey)
         
        let entityBounds = ey.visualBounds(relativeTo: ey.parent)
        let extents: SIMD3<Float> = [entityBounds.extents.x, entityBounds.extents.y, entityBounds.extents.z]
        self.collision = CollisionComponent(shapes: [ShapeResource.generateBox(size: extents).offsetBy(translation: entityBounds.center)])
         
        DispatchQueue.main.async {
          cancellable?.cancel()
          cancellable = nil
        }
      })
  }
ey.availableAnimations.forEach {
    if #available(iOS 15.0, *)
    {
      ey.playAnimation($0.repeat())
    }
  }

The animation does not play. Skeletal animation!

I can't quite tell when you are triggering the animation, but for me,

I do not play an animation as soon as the model with an animation is loaded. Instead I wait until my ARSessionDelegate function

func session(ARSession, didUpdate: ARFrame)

is called.

Also, as a side note, in the past only one animation is loaded into the Entity.

USDZ:https://sketchfab.com/3d-models/spartan-armour-mkv-halo-reach-57070b2fd9ff472c8988e76d8c5cbe66

USDZ Animations with RealityKit 2
 
 
Q