Track Switching
This tutorial goes over how to seamlessly switch between two tracks.
- Introduction
- Getting started
- Tutorial template
- Requirements for seamlessly switching between two tracks:
- Tracks must be lined up at the given positions
- They must be positioned in a way such that the shape of the model (in this case, a train), will be the same when switching between the two tracks.
- The easiest way to do this is to have them layered on top of the other
- (Obviously when switching between two different track classes this will be different, but in this tutorial we will be using PointToPoint2)
- Use the
None
transition type in the keyframe when recording- Prevents a "jump" in the positioning of the train
- Set length to
0
- Prevents a "jump" in the positioning of the train
- Prevents it from stopping for a frame
- Recalculate length afterwards
- This shouldn't change our current length since we are editing the very last keyframe
- It's good practice to recalculate the internal length every time we manually edit a keyframe's data
- Tracks must be lined up at the given positions
- Simulate to our stop
- Switch tracks
- Simulate out
local lastKeyframe = keyframeRecorder:getLast()
lastKeyframe.transitionType = TransitionType.None
lastKeyframe.length = 0
keyframeRecorder:recalculateLength()