I am trying to control multiple skeletal animations at the same time with multiple inputs, each of which points to a different frame of an animation. Imagine the way you set weight for a morpher with
setWeight(_:forTargetAt:)
, but with input as a frame which I want the animation to be in state of.I achieved this for just one animation by doing something like
@IBOutlet weak var sceneView: SCNView!
var animationPlayer: SCNAnimationPlayer! = nil
override func viewDidLoad() {
super.viewDidLoad()
//add a node on the scene and give animationPlayer the node's animation player
animationPlayer.animation.usesSceneTimeBase = true
}
@IBAction func sliderChanged(_ sender: UISlider) {
sceneView.sceneTime = Double(sender.value) * animationPlayer.animation.duration
}
where a slider is put to change the
sceneTime
of sceneView
. This could only work if the node has just one animation.But what I want to achieve is controlling all the animations asynchronously but on one node. I cannot simply play with
sceneTime
because that will cause all the animations to be played on the same time base in sync.Is there any way to play all the animations with different input time or any value that works as a pointer to a specific frame of the animation?
(e.g. at one point, first animation is playing the 5th frame while second is in state of 8th. At next frame of rendering, the first animation is playing 4th frame and the second is playing 12th frame.)
Thanks.