I am trying to animate a bicycle so that it rides around in a circle. Right now I have
transform.translation = [0.5, 0, 0]
// Define an orbit animation
let animationDefinition = OrbitAnimation(duration: 5, axis: [0, 1, 0], startTransform: transform, bindTarget: .transform, repeatMode: AnimationRepeatMode.repeat)
let animationResource = try! AnimationResource.generate(with: animationDefinition)
scene.playAnimation(animationResource)
The problem is that the bike does not face forward. Rather it looks like it's on a turntable.
I tried to blend a rotation with BlendTreeAnimation but that doesn't seem to be working.
It turns out there's an easy built in way to do this using
orientToPath. Just pass that toOrbitAnimationand set it totrue.Now the bike always faces forward relative to its current position on the orbit.