How does the Badger's Cart follow the rails in the the "Badger Advanced Rendering in SceneKit" sample code?

I am trying to understand how the "Badger Advanced Rendering in SceneKit" sample code makes the badger's mine cart follow the path represented by the rails/train tracks. I am not seeing just where in code or in a resource such as a .scn file that this is managed. One clue - I find that if I eliminate sections of track, it will still follow the path they represent. So it does not appear to be related to some aspect of the rails themselves. But I am still not seeing what governs the cart moving along the elaborate path...

Replies

I am reading between the lines, believe I there is an animation on the root node of scene.scn named "WIP_0601-1" that defines the movement and rotation of the cart in the game. I am not sure if or how to see this in the SceneKit Editor (I have worked a lot with .dae, but am just learning .scn files).


If you look at ViewController.init(coder:) [line 183] you will see the key for this animation assigned to self.cartAnimationName. The animation for this key is used in ViewController.viewDidLoad [line 391-394] to setup an event that respawns the collectables when the animation is 90% complete. The animation is added at line 395. As the game runs ViewController.updateSpeed() is called to change the speed of this animation, which is intially set to zero in viewDidLoad (characterSpeed = 0.0).