Put the new animation in a separate USDZ file and load it to the code then apply each when needed on the desired entity, which should be identical to the entity that have the external animation.
import SwiftUI
import RealityKit
struct ImmersiveView: View {
@State var entity = Entity()
@State var extEntity = Entity()
var body: some View {
RealityView { content in
//Loading Main USDZ With Main Animation And Link it
let mainAnim = try! await Entity(named: "main.usdz")
if let item = mainAnim.findEntity(named: "SOME ENTITY")
{
entity = item // The Entity of the object you want to animate
content.add(entity)
}
//Loading External Animation And Link it
let extAnim = try! await Entity(named: "external.usdz")
if let item = extAnim.findEntity(named: "SOME ENTITY")
{
externalEntity = item // The Entity Of the Object have the external Animation
}
Then somewhere in your code when you want to apply the external animation
func playExtraAnimation()
{
entity.playAnimation(extEntity.availableAnimations[0], transitionDuration: duration , startsPaused: true)
}