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

Freight Cars: Intermediate Features

The basics tutorial gets you a working, drivable freight car. From there, a handful of intermediate features turn a plain model into a proper piece of rolling stock: painted lettering, recolorable paint schemes, and moving parts like doors. These concepts apply equally to locomotives, passenger cars, and other rolling stock.

Decals add road numbers, reporting marks, the railroad name, or a data plate to the car (the text goes in the content field). Color is driven by the style system via a styleClass; placement comes from the Decal component’s own transform.

A decal is drawn by a projector that projects along its local +Z (blue) axis. When you add a Decal component in the Definition Editor, you set its size (width and height on X and Y, plus a shallow Z depth), then position it to overlap the side of the car. The projector’s origin sits at the center of this box. Keep the depth small: 0.05 (5 cm) is a good default. Too shallow and the decal may Z-fight; too deep and it bleeds onto faces it shouldn’t touch. A decal has no awareness of the geometry it projects onto; it passes straight through to any deeper faces inside the box.

Use decals sparingly, especially Image decals. The Data content type helps by packing several fields (capacity and weight, dimensions, build date, and so on) into a single decal. If you author custom decal content, consolidate it into as few decals as you can.

Features that reference materials or animations need Railroader to resolve a Unity Material or AnimationClip at runtime. It does this through maps: MonoBehaviour components you add to the prefab in the ADK that give each asset a name. MaterialMap names materials, for RendererGroup; AnimationMap names animation clips, for the animation components.

Both features below depend on this, so set the maps up first. See Material & Animation Maps for how to add them and what reads them. When a feature below “can’t find” a material or clip, a missing map entry is the first thing to check.

A RendererGroup names one material on the model, and so describes the set of renderers that use it, including individual submeshes within a mesh. Those renderers can then be styled together by giving the group a styleClass (for example "body", "trim", or "lettering"), which connects them to the style system, or driven by a script through the Material API. This is what makes a car recolorable, and it is the foundation for style variants and player customization.

At runtime Railroader sets the material’s base color (_BaseColor). The shader multiplies the base-color texture by this value, so for the color to reproduce accurately the texture should be predominantly white.

Moving parts such as a sliding door use ToggleAnimation, which references an animation clip by name (resolved through the prefab’s AnimationMap) and plays it in response to player interaction. As with the collider in the basics tutorial, the interactive part sits on the Clickable layer so the player can click it.

  • Styles and CarStyle — define color palettes and style variants on top of the renderer groups above.
  • Relay — scripted behavior, including deeper customization and paint maps.