Skip to content
You're reading the docs for Railroader 0.6 (the MoW Update), currently available on the Experimental branch.

Material & Animation Maps

If your mod needs to reference materials or animations on a model, you need a way to resolve their names to the bundled asset. Two components bridge that gap: MaterialMap and AnimationMap. Add these components to your model’s prefab in the ADK and list each material or animation clip you want a definition to be able to name. Anything that references a material or an animation by name (a RendererGroup, a ToggleAnimation, a car’s brake rigging) resolves it through one of these maps.

Without one of these maps the material or animation clip may not be included in the built Unity asset bundle, and Railroader won’t be able to resolve the reference at runtime.

The maps also help to isolate Railroader definitions and scripts from asset filename changes.

Open your prefab in the ADK Unity project. Select the prefab and click Add Component. Find Material Map or Animation Map. Then add one entry per asset — a name you choose, plus the Material or Animation Clip it refers to.

The name is yours to pick. It’s what you type into the definition, and what the Definition Editor offers in its Material and Animation dropdowns, so name entries for whoever reads the definition later (Body, Door Open) rather than after the asset file.

Railroader finds the map component anywhere on the prefab. Only create one: the first component of each type found is used. Others are ignored.

Put the AnimationMap on the model root (the object created from your FBX) rather than the outer prefab root. Railroader looks for the Animator on whichever GameObject carries the AnimationMap (and on cars and locomotives, adds one there if it is missing), and an animation clip’s curves are addressed relative to that object. A map on the wrong object gives you an animation that plays and moves nothing.

MaterialMap supplies materials to:

WhereField
RendererGroup componentmaterial

AnimationMap supplies animation clips to:

WhereField
ToggleAnimation, LoadAnimation, RadialControl, Bell, Compressor componentsanimation
Car definitionbrakeAnimations
Truck definitionbrakeAnimation, wheelset animation

A referenced name with no matching entry stops the model from loading, with the map’s own name in the message:

Couldn't find material named Body in my-boxcar
Couldn't find animation named Door Open in my-boxcar

Two things produce this: no entry by that name, or an entry whose Material/Clip slot is empty. Renaming an animation clip in your modeling tool is the usual cause — the map keeps the old name, and the definition keeps referencing it.

A truck model must have an AnimationMap. It supplies the brake rigging clip named by the Truck definition’s brakeAnimation, along with the wheel rotation clip. A truck prefab without one fails with Truck <identifier> model has no AnimationMap.

A MaterialMap on a truck is optional. Add one to give the truck a named material that a RendererGroup can recolor, the same way a car body’s does — that’s how a truck picks up a style.

Each engine set on an ArticulatedSteamLocomotive carries its own AnimationMap, holding that set’s clips (Front Brakes and the like). Names resolve against the engine set’s own map rather than the main body’s, so each set needs its own maps.

The same goes for components: a component whose parent is inside an engine set takes its animations from that set’s AnimationMap. Materials come from the set’s MaterialMap if it has one, and otherwise from the main body’s.