MovingSectionCFrameTrack
Combines two tracks such that the shape of one track can be used on another. One is considered the "root" or main. The other, which is optional, is considered the section that defines this shape. The shape is mainly used for the offset positioning of trains.
SectionOffsetTypes
SectionOffsetType determines how to calculate the final "shape" of a group of a positionsOffsets.
By default (SectionOffsetType = 0), the track uses sectionPosition
property
Origin and Offset
Origin is a world space position used to calculate a new "origin" or (0, 0, 0) CFrame value.
The origin is determined by the rootTrack
and the current position
given by the animation player.
Offset is the local space position to this Origin.
The origin is determined by the sectionTrack
and the sectionPosition
and further adjusted via the sectionOffsetType
SectionPosition = 0 (Default)
Offset is determined by sectionTrack:getCFrame(sectionPosition)
.
SectionOffset = 1
Uses an additional offset from the "SectionPosition" using the sectionOrigin
CFrame property.
sectionOffset = sectionOrigin:Inverse() * sectionTrack:getCFrame(sectionPosition)
In the InstanceData, if SectionOriginRootPosition
exists, then this sectionOrigin
is calculated from the offset of the "SectionPosition"
to rootTrack:getCFrame(sectionOriginRootPosition)
. This makes it easy to calculate from the existing track.
See the example below for more information.
SectionOffsetRotation = 2
Combination of SectionPosition and SectionOffset where the "SectionPosition" is used as the Position and "SectionOrigin" is used as the rotation to form the final Offset.
Example: Getting Shape of "Overlapped" Tracks
This example allows for seamless transitions when switching between two "overlapped" tracks.
Useful for turntables, transfer tracks, elevator lifts, tilt drops, and more.
You will need to set both the SectionPosition
and SectionOriginRootPosition
values to the position at the overlap of the two tracks.
- Think of it as this as the intersection of the two curves
- You will need to adjust this if your
CFramedTrain
Model uses a differentMidPoint
note
For those generating animations, this would be where it transfers from and to.
The SectionTrack
would be where it transfers "from".
The RootTrack
would be where it transfers "to".
It can also be vice versa, just remember that the SectionTrack
is the "shape" and the RootTrack
is the "movement".
- Use
SectionOffsetType
"SectionOffset" or1
- Set the
SectionPosition
value to this position at theSectionTrack
- Set the
SectionOriginRootPosition
value to this position at theRootTrack
Types
SectionOffsetType
enuminterface
SectionOffsetType {
SectionPosition:
0
--
Offset origin is determined by sectionPosition
when passed to sectionTrack:getCFrame()
SectionOffset:
1
--
Offset origin is determined by MovingSectionCFrameTrack.sectionOffset
SectionOffsetRotation:
2
--
Offset origin is determined by the CFrame's Position value of sectionPosition and the rotation of MovingSectionCFrameTrack.sectionOffset
}
Properties
rootTrack
MovingSectionCFrameTrack.rootTrack:
CFrameTrack
The main track used for determining positioning
sectionTrack
MovingSectionCFrameTrack.sectionTrack:
CFrameTrack?
Determines the "shape" of the section used to offset the model's position from the rootTrack
.
If nil, section will be considered "straight" and offsets will just use the -Z axis of the CFrame returned by rootTrack
sectionOffsetType
MovingSectionCFrameTrack.sectionOffsetType:
number
How it calculates the offsets for the sectionTrack See SectionOffsetType for more info.
sectionPosition
MovingSectionCFrameTrack.sectionPosition:
number
The position on the sectionTrack
which will be used when calculating the offset.
See SectionOffsetType for more info.
sectionOffset
MovingSectionCFrameTrack.sectionOffset:
CFrame
A CFrame offset value used when calculating the offset. See SectionOffsetType for more info.
Functions
new
ConstructorMovingSectionCFrameTrack.
new
(
sectionOffsetType:
number?
,
--
default = SectionOffsetType.SectionPosition
sectionPosition:
number?
,
--
default = 0
) →
MovingSectionCFrameTrack
Default Constructor
fromInstance
ConstructorCreates from an Instance
Children
{
RootTrack: CFrameTrackInstance | ObjectValue<CFrameTrackInstance>,
SectionTrack: CFrameTrackInstance | ObjectValue<CFrameTrackInstance> | nil,
SectionOffsetType: IntValue?, // if nil, `sectionOffsetType` defaults to `SectionOffsetType.SectionPosition`; see SectionOffsetType for values
SectionPosition: NumberValue?, // if nil, `sectionPosition` is set to `0`
SectionOrigin: CFrameInstance?, // if nil, `sectionOrigin` is set to `CFrame.new()`
SectionOriginRootPosition: NumberValue?, // if nil, `sectionOriginRootPosition` is set to `0`
}
Notes
SectionOriginRootPosition
gets the sectionOrigin value fromrootTrack:getCFrame(sectionOriginRootPosition)
.- If SectionOrigin exists, SectionOriginRootPosition is not used.
getCFrame
overrideReturns a CFrame
getPositionOffsetCFrames
overrideMovingSectionCFrameTrack:
getPositionOffsetCFrames
(
position:
number
,
positionOffsets:
{
number
}
) →
{
CFrame
}
Returns a list of CFrames from position offsets