So I essentially created a timeline event that is essentially an orbit animation. I gave the referred entity and the pivot entity and everything is working as intended in Reality Composer pro. Good!
My struggle is now to make it "start" when I run my app. It appears that just loading the scene is not enough. I am not doing anything complex:
var body: some View {
RealityView { content in
do {
let scene = try await Entity(named: "Scene", in: realityKitContentBundle)
content.add(scene)
openWindow(id: "ButtonOverlay")
} catch {
print("Failed to load scene: \(error)")
}
}
}
What I would like to do is "start" the timeline in Reality Composer pro, in code. This can be done as soon as I load the entities, or even after touching the entity in the scene
Can someone help?
Select the 3D model in RCP 2.0 and click Add Component
button in the right panel. You'll see a components' dialog where you'll need to select a Behavior
component. Now you can choose one to four options listed below. When you choose the third option, you won't need to additionally write a single line of code because the timeline animation will start automatically (just load the scene from RCP).
Once a model is loaded, the timeline animation will immediately begin playing.
import SwiftUI
import RealityKit
import RealityKitContent
struct ContentView : View {
let rkcb = realityKitContentBundle
var body: some View {
RealityView { rvc in
let sph = try! await Entity(named: "Scene", in: rkcb)
sph.position = [0.0, 1.0,-2.0]
rvc.add(sph)
}
}
}