3d object animation

how do make animation work? my "model3d" has animation in when I open it in reality composer pro but in simulator it's static.

import SwiftUI import RealityKit import RealityKitContent

struct ContentView: View {

var body: some View {
    ZStack(alignment: .bottom) {
        RealityView { content in
            if let scene = try? await Entity(named: "model3d", in: realityKitContentBundle) {
                content.add(scene)
            }
        }
    }
}

}

Hey @lukejyoon try this inside of your scene:

let anim = scene.availableAnimations.first?.repeat(count: 1) {
        scene.playAnimation(anim)
        content.add(scene)
 }

So your code should be like this:

var body: some View {
    ZStack(alignment: .bottom) {
        RealityView { content in
            if let scene = try? await Entity(named: "model3d", in: realityKitContentBundle) {
                content.add(scene)
                  let anim = scene.availableAnimations.first?.repeat(count: 1) {
                  scene.playAnimation(anim)
                   content.add(scene)
                  }
            }
        }
    }
}
}
3d object animation
 
 
Q