How do I continuously rotate a model during OrbitAnimation so that the model is facing forward?

30 views Asked by At

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.

1

There are 1 answers

0
wonton On

It turns out there's an easy built in way to do this using orientToPath. Just pass that to OrbitAnimation and set it to true.

let animationDefinition = OrbitAnimation(duration: 5, axis: [0, 1, 0], startTransform: transform, orientToPath: true, bindTarget: .transform, repeatMode: AnimationRepeatMode.repeat)

Now the bike always faces forward relative to its current position on the orbit.