Skip to content

Train Model Setup

This section will teach you how to "rig" a train model for the Animation Player.

In this system, the movement of the trains are based around the wheelsets, which are always a set track distance away from each other.

InstanceData Children Tree

Here's what we want are final train model to look like.

// Anything that is an Instance is usually a Folder or Model.
// Anything that is a Model must have it's PrimaryPart set.
// Anything prefixed with "?" is optional.
// CFrameInstance is anything that can be converted into a CFrame.
//  - BasePart
//  - CFrameValue
//  - Vector3Value
//  - ObjectValue->CFrameInstance

instanceData: Instance
    +--> Cars: Instance
    |       +--> 1: Instance
    |       |       +--> CFrameCalculationType: IntValue
    |       |       +--> FrontConnector: CFrameInstance
    |       |       +--> RearConnector: CFrameInstance
    |       |       +--> Chassis: Model
    |       |       +--> ?WheelSetA: Model
    |       |       +--> ?WheelSetB: Model
    |       ...
    |       +--> N: Instance
    |               + ...
    +--> Connectors: Instance
    |       +--> 1: Model
    |       |       +--> FrontCar: IntValue
    |       |       +--> RearCar: IntValue
    |       ...
    |       +--> N: Instance
    |               + ...
    +--> Seats: Instance
            +--> 1: Instance/ObjectValue
            |       +--> 1: Instance/ObjectValue
            |       |       +--> 1: Seat/ObjectValue
            |       |       +--> N: ...
            |       +--> N: ...
            +--> N: ...

Class Definitions

to make it more customizable.

CFrameInstance

Anything that has or can be converted into a CFrame

  • BasePart
  • CFrameValue
  • Vector3Value
  • ObjectValue whose Value is any of the above classes

Cars

CarModel: Instance
    +--> CFrameCalculationType: IntValue
    +--> FrontConnector: CFrameInstance
    +--> RearConnector: CFrameInstance
    +--> Chassis: Model
    +--> ?WheelSetA: Model
    +--> ?WheelSetB: Model

Each Car model must be named numerical order from 1 to N, with 1 being the front car and N being the rearmost car.

Note: At the moment, this system does not support so called "zero-cars". These are cars connected to one-another using a hinge rather than a ball-socket joint and help to stablize and balance the train. To create something similar, you would need to combine the two cars into one and have the rear car's WheelSet be WheelSetB

CFrameCalculationType

IntValue

The CFrameCalculationType tells the system how we want the Chassis to be positioned.

CFrameCalculationType {
    OffsetFromWheelSetA: 0,
    OffsetFromFrontCar: 1,
    OffsetFromRearCar: 2,
    OffsetBetweenWheelSets: 3,
}

OffsetFromWheelSetA

Moves the train based on the offset from this car's WheelSetA.

OffsetFromFrontCar

Moves the train based between this car's WheelSetA and the front car's front most wheelset. If WheelSetB exists, then it is WheelSetB, otherwise it is WheelSetA.

OffsetFromRearCar

Moves the train based between this car's WheelSetA and the rear car's WheelSetA

OffsetBetweenWheelSets

Set to this if your train has both a WheelSetA and a WheelSetB.

WheelSetA

Model

This is the frontmost WheelSet of your car.

WheelSetB

?Model

Not required.

This is the rearmost WheelSet of your car.

Chassis

Usually our guests will sit. Can include Seats.

FrontConnector

?CFrameInstance

Used with Connectors.

RearConnector

?CFrameInstance

Used with Connectors.

Connectors

Honestly, they are kind of an afterthought because of how the system is designed. Still, you want to get as much realism as you can.

Each Connector model must be, well, a Model with a PrimaryPart.

FrontCar

IntValue

Index of the front car this connector is connected to.

RearCar

IntValue

Index of the rear car this connector is connected to.

Seats

Seats are the most complex to setup. The Seats container is located outside of the Cars container, yet a Seat Instance must be localted inside of a Car so that it moves with it.

3-dimensional Array - Cars - Rows - Seats

[Car] --> [Row] --> [Seat]

ObjectValues