1

I'm trying to animate the movement of an entity but at the end of the animation the entity disappears. It occurs if you animate the scale or translation but not rotation. I'm not sure if it's a bug or expected behaviour but I would like to find a way to stop it.

let transform = Transform(scale: simd_float3.one, 
                       rotation: simd_quatf(), 
                    translation: [0.05, 0, 0])

let animationDefinition = FromToByAnimation<Transform>(by: transform, 
                                                 duration: 1.0, 
                                               bindTarget: .transform)

if let animationResource = try? AnimationResource.generate(with: animationDefinition) {
    entity.playAnimation(animationResource)
}

I know you can use entity.move() and that works fine but I want to explore other ways to animate entities.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Mark Horgan
  • 3,243
  • 4
  • 27
  • 28

1 Answers1

0

This transform animation works as expected. Fix the opacity of your model, if it has translucent materials (for that use USDZ Python Tools commands fixOpacity and usdARKitChecker). Also, check if any transformation ​​are applied to the entity on which you are running the transform animation.

 let boxScene = try! Experience.loadBox()
 boxScene.children[0].scale *= 3
 arView.scene.anchors.append(boxScene)
    
 let entity = boxScene.children[0].children[0]
    
 let transform = Transform(scale: simd_float3.init(2, 2, 2),
                        rotation: simd_quatf.init(angle: .pi, axis: [1, 1, 1]),
                     translation: [0.4, 0, 0])
    
 let animationDefinition = FromToByAnimation<Transform>(by: transform,
                                                  duration: 2.0,
                                                bindTarget: .transform)
    
 if let anime = try? AnimationResource.generate(with: animationDefinition) {
     entity.playAnimation(anime)
 }

enter image description here

As you can see from this example, after applying the animation, the entity does not disappear.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220