Search code examples
swiftxcodearkitrealitykitreality-composer

How to trigger an entity's animation declared in .reality file?


In Reality Composer I created MyScene.rcproject, in MyScene I created a panel and its spin animation, the action sequence begins when its notification is posted from code.

enter image description here

When it's come to trigger the animation from MyScene.rcproject it works like I expect:

self.sceneAnchor = try MyScene.loadMyScene()
sceneAnchor.generateCollisionShapes(recursive: true)
sceneAnchor.notifications.spin.post()

But when I export MyScene.rcproject file to MyScene.reality and I implement it into another app project:

panelEntity = try? ModelEntity.load(named: "MyScene")
sceneAnchor.addChild(panelEntity)

I can't find any method to trigger the spin animation. Is it possible to trigger entity's animation, inside MyScene.reality file?


Solution

  • In RealityKit 2.0, if using .reality file instead of .rcproject, Notifications class is inaccessible.

    public private(set) lazy var notifications = A.Scene.Notifications(root: self))