Train Controller (Railroad System) v3.4

About Train Controller (Railroad System) v3.4 – Unity Editor Tool & Plugin

Train Controller (Railroad System) v3.4 Unity Asset Overview

The Train Controller (Railroad System) v3.4 utilizes a decoupled, component-based framework designed around kinematic track evaluation and event-driven signals. Rather than relying entirely on standard Unity wheel physics—which often introduce jitter and derailment artifacts at high speeds—the core movement model relies on analytic mathematical curves calculated along continuous spline paths, synchronized with a deterministic physics update loop.

Core Script Topology

The system’s runtime logic is anchored by several interconnected manager and controller scripts:

Zero-Allocation Path Tracking

To eliminate per-frame Garbage Collection (GC) allocations, the spline tracking algorithm avoids dynamic list instantiation and heap allocations during frame evaluation. Positions and tangents along the rail path are derived using pre-allocated native arrays or value-type structs passed by reference. Below is an example implementation demonstrating the non-allocating rail update routine used within the movement engine:

using UnityEngine;
using UnityEngine.Events;

namespace DynamicRailSystem
{
    [RequireComponent(typeof(Rigidbody))]
    public class RailFollower : MonoBehaviour
    {
        [SerializeField] private TrackSegmentSO _activeTrackData;
        [SerializeField] private float _targetVelocity = 20f;
        [SerializeField] private float _acceleration = 3.5f;

        [Header("Events")]
        public UnityEvent OnVelocityUpdated;
        public UnityEvent OnSignalPassed;

        private float _currentDistance;
        private float _currentVelocity;
        private Rigidbody _rb;

        private void Awake()
        {
            _rb = GetComponent();
            _rb.isKinematic = true;
            _rb.interpolation = RigidbodyInterpolation.Interpolate;
        }

        private void FixedUpdate()
        {
            if (_activeTrackData == null) return;

            // Accelerate smoothly toward target velocity using delta time
            _currentVelocity = Mathf.MoveTowards(_currentVelocity, _targetVelocity, _acceleration * Time.fixedDeltaTime);
            _currentDistance += _currentVelocity * Time.fixedDeltaTime;

            // Non-allocating spline evaluation using struct references
            _activeTrackData.EvaluatePointAndRotation(_currentDistance, out Vector3 targetPos, out Quaternion targetRot);

            _rb.MovePosition(targetPos);
            _rb.MoveRotation(targetRot);

            OnVelocityUpdated?.Invoke(_currentVelocity);
        }

        public void SetTargetVelocity(float velocity)
        {
            _targetVelocity = velocity;
        }
    }
}

Inspector Configuration & Workflow

The editor environment for Train Controller (Railroad System) v3.4 relies heavily on custom property drawers, visual Handles API scene viewers, and ScriptableObject data containers. This isolates engine parameters and rail layouts from visual assets, allowing technical artists and designers to iterate without risking scene corruption.

ScriptableObject Data Structures

Vehicle physics and line profiles are configured via distinct ScriptableObjects:

Scene-View Tools & Custom Property Drawers

The visual editor features inline custom inspectors that automatically render contextual controls inside the Scene View. Switch points can be toggled via clickable GUI buttons directly in the editor window. Custom Property Drawers provide visual curve previews for brake responsive curves and torque drop-offs directly within the Inspector panel, eliminating context switching between script settings and external editors.

Performance Profiling & Optimization Guidelines

Operating complex railroad systems with high car counts presents unique performance challenges regarding physics calculations, draw calls, and script execution overhead. The system uses specific architecture design choices to keep execution limits within tight mobile and VR performance budgets.

Kinematic Evaluation vs. Rigidbody Physics

Traditional rigidbodies controlled via forces often fail at track switches or high speeds due to variable solver iterations. This architecture resolves movement analytically while maintaining dynamic physics interaction using Kinematic Rigidbodies:

Performance Comparison Overview

Quick-Start Unity Integration Guide

Implementing the system into a clean scene requires establishing a track layout before instantiating train prefabs. Follow these steps to establish a functional prototype loop.

Step 1: Network & Track Creation

Create an empty GameObject in your hierarchy and attach the RailNetworkManager component. Use the editor menu (Tools > Railroad System > Create Track) to instantiate your first track node. Extend the track by holding the designated editor hotkey and clicking in the Scene View to place continuous spline knots. The editor automatically generates MeshCollider components along the rail path for wheel interaction audio and particle alignment.

Step 2: Locomotive Engine Setup

Drag a train engine 3D model into the scene. Attach the TrainController script along with a standard Rigidbody component. Assign a valid LocomotiveProfileSO configuration file to the controller's profile slot. In the hierarchy, attach two child GameObjects representing the front and rear bogies, and link these references to the FrontBogieAnchor and RearBogieAnchor fields inside the Inspector.

Step 3: Carriage Coupling & UI Hookup

Place trailing carriage prefabs behind the locomotive. Add the TrainCarriage component to each car. Using the custom Inspector utility, click Auto-Detect Couplers to align front and rear coupler joints. Finally, add the dynamic UI prefab into your Canvas and link the OnVelocityUpdated listener from the primary TrainController component to update the speed meter readout automatically at runtime.

Asset Details & Specifications

CategoryTemplates / Systems
Latest Versionv3.4.1 (2 tracked releases)
File Size348.69 MB
Added to PlatformFebruary 5, 2026
Views5 views
Downloads0 downloads
Favourites0 favourites
Official StoreBuy Original License on Unity Asset Store →
Issue with Package?Report Broken Link →

Related Unity Templates Assets