On this page
Module guide

Minibus Route

Serve ordered bus stops in an RCCP 2 vehicle and keep the ride comfortable.

The example vehicle includes a seated driver. RCCP 2 core supplies the driver model and controller.

Install the module

If you imported the complete Driving Sandbox, this module is already installed. Go to the next section. Use these steps only for RCCP2-MinibusRoute.unitypackage, made with Export Module > Minibus Route.

Installation order for Minibus Route
  1. If any required packages are missing, install Input System, Editor Coroutines and Unity UI in Package Manager.
  2. Install Realistic Car Controller Pro 2 v4.1.3 or later. The RCCP 2 installer stops if a required package is missing.
  3. Open Edit > Project Settings > Player > Other Settings.
  4. Set Active Input Handling to Input System Package (New) or Both.
  5. If Unity requests a restart, restart the Editor.
  6. If TMP Essential Resources are missing, select Window > TextMeshPro > Import TMP Essential Resources.
  7. Use Assets > Import Package > Custom Package to import RCCP2-MinibusRoute.unitypackage.

Drive the example

Minibus Route at the start of Play Mode
No. Item
1 RCCP dashboard: speed, gear and engine RPM
2 Next stop or boarding step
3 Stops, riders and comfort
4 RETRY button
5 INFO button
6 Route sign
  1. Open Assets/RCCP 2 Driving Sandbox/Modules/MinibusRoute/Samples/Minibus Route Example.unity.
  2. Enter Play Mode.
  3. Drive straight ahead to 01 DEPOT, 02 MARKET and 03 TERMINAL. Stop inside each yellow rectangle and face the bay arrows.
  4. Hold still while the passengers board. A stop takes about 7 to 15 seconds.
  5. Continue past Terminal. Follow the yellow arrows left into the return lane.
  6. Serve 04 RETURN MARKET and 05 RETURN DEPOT. Both bays face back toward the depot.
  7. At ROUTE COMPLETE, select RETRY to return to the start. The route clears the passenger count and restores comfort to 100.
Stops on the outbound and return legs
The five bays in the Scene view

Select INFO in the HUD to see the controls, rules and setup steps.

The Info panel

The example uses the Classic Minibus in Samples/Classic Minibus/Classic Minibus.prefab. The challenge uses a vehicle footprint of 2.25 × 5 m.

At the first stop, wait for the group to board through the rear doors. At later stops, the previous group exits first. The sample boards 3, 4, 5, 2 and 3 passengers in route order. The HUD adds the new group when the last passenger boards and both doors latch. The route disables driving input during this time. Use gentle throttle and brake inputs to keep the comfort score high.

Task result feedback

Minibus Route result banner

The HUD shows a green banner after you serve the last stop. The HUD keeps the stop count, passenger count and comfort score until you select RETRY.

The banner stays fully visible for 3 seconds between fades. A new attempt hides the banner sooner. Play continues during the banner. You can use the HUD buttons while the banner is visible.

The supplied HUD has a Result Notification reference. Clear Result Notification to hide the banner and keep the standard HUD. Keep the included Shared/UI/SandboxTaskNotification.cs script in the project when you use the HUD.

Controls

Action Key
Throttle W or Up Arrow
Brake and reverse S or Down Arrow
Steer A / D or Left / Right Arrow
Handbrake Space
Change camera C
Retry or Info Select the HUD button
Minibus Route keys

Use it in your scene

If you use the complete Driving Sandbox, open your scene. Select your RCCP vehicle in the Hierarchy. On the Minibus Route card, select Add to Scene.

Move 01 STOP and 02 STOP to your stops. Point each bay in the direction of travel. Set Stop Name and Passengers on each bay. Complete any other steps in the setup dialog.

Relative asset paths start at Assets/RCCP 2 Driving Sandbox/Modules/MinibusRoute/.

In a single module package, or to do it manually, use these steps.

Before you start, prepare a scene with a solid driving surface. To test, drag Samples/Classic Minibus/Classic Minibus.prefab into the scene. Place the vehicle at its normal spawn height above the surface.

To add a driving camera, select Tools > BoneCracker Games > Realistic Car Controller Pro 2 > Add to Scene > RCCP Camera. Then disable the original Main Camera. For the dashboard, select Tools > BoneCracker Games > Realistic Car Controller Pro 2 > Add to Scene > UI Canvas.

If the scene has no RCCP Scene Manager, select Tools > BoneCracker Games > Realistic Car Controller Pro 2 > Add to Scene > Scene Manager. If the scene has more than one vehicle, assign your vehicle to Active Player Vehicle on RCCP Scene Manager. Clear Register Last Vehicle As Player. If this option is on, the last eligible vehicle can take the player slot at startup.

  1. Place the RCCP vehicle at the route start.
  2. Create an empty GameObject. Select Add Component > BoneCracker Games > Driving Sandbox > Minibus Route > Minibus Route Challenge.
  3. Drag the vehicle from the Hierarchy to Vehicle. If you spawn the vehicle at runtime, set the Vehicle property in your code.
  4. For each stop, add Prefabs/Boarding Bay.prefab. Put it at the center of the bay, 0.63 m above the road.
  5. Set the tool handle rotation to Local. Turn each bay until its blue Z axis points in the direction of travel.
  6. On each bay, set Stop Name and Passengers on the Minibus Route Stop component.
  7. Assign each bay once to Stops in service order. For a return leg, add the return bays after the outbound bays.
  8. Set Vehicle Footprint to the width and length of the vehicle in meters. The footprint is a rectangle centered at the Rigidbody origin.
  9. Set the Size of each bay to contain the whole footprint when the vehicle stops. Select the bay to see its gizmo. The painted markings do not change with Size.
  10. Set Heading Tolerance, Stop Speed Tolerance and Dwell Duration. To set a specific restart pose, put the vehicle at its start pose. Create an empty GameObject with the position and rotation of the vehicle root. Keep the spawn at the vehicle root height. Assign the object to Retry Point.
  11. To display the route, add Prefabs/Minibus Route HUD.prefab. Assign the challenge to Challenge on the HUD.
  12. If the scene has no EventSystem, select GameObject > UI > Event System. Use an Input System UI Input Module on the EventSystem.
Minibus Route: 1 Vehicle, 2 Retry Point, 3 Stops, 4 Vehicle Footprint. Minibus Route HUD: 1 Challenge
Minibus Route Stop: 1 Stop Name, 2 Size, 3 Passengers. The sample boarding script
The cyan gizmo is the bay volume. The yellow markings are painted
The example hierarchy

The HUD prefab has its own Canvas. Its RETRY button calls Retry() on the assigned challenge. Use one challenge for each route.

To board passengers, the whole footprint must stay inside the bay volume. Keep the vehicle upright relative to the bay and face the bay arrows. Stay at or below the speed limit for the full dwell time. The route sets canControl to false during the dwell. If a boarding condition fails, the dwell timer returns to zero. When boarding ends or stops, the route restores the previous canControl value.

The example uses a 12° heading limit and a 1 km/h stop limit. Set Dwell Override on a stop to give it a different duration. Zero uses the route duration.

The INFO panel in the HUD describes the example. Change the text or delete the INFO button in your scene.

The Classic Minibus, the passenger models and Samples/MinibusSampleBoarding.cs are sample parts. The route works without them. When the Console shows a warning from Minibus Route Challenge, the warning names the field to fix.

Sample boarding

The example adds passengers and rear-door movement with Samples/MinibusSampleBoarding.cs on the Route Boarding object. This script is sample-only. It is made for the Classic Minibus and this example scene. Without it, each stop uses Dwell Duration or Dwell Override.

At the first stop, the group boards. At later stops, the previous group leaves through the rear doors, then the new group boards. The script extends the dwell to the length of this movement. In the example, a stop takes 6.8 to 14.7 seconds. The stop ends after the full dwell, when the last passenger sits and both rear doors latch. RETRY closes the doors and returns the passengers to their first positions.

Stop times measured in the example
Field Requirement
Challenge The route. Its Vehicle must be the Classic Minibus when Play starts.
Left Door and Right Door The ConfigurableJoint on Door_Rear_L and Door_Rear_R. Each door needs an RCCP_DetachablePart with Lock At Start on, a Rigidbody, a Connected Body and angular X limits.
Styles One or more passenger styles. Each style needs a Model, the Idle, Walk, Step and Seated clips and a Scale above zero.
Passengers on each stop 7 or fewer. The script has 7 Classic Minibus seat positions.

Limits of the sample script:

  • Seat, door and walk positions are fixed offsets for the Classic Minibus. On another vehicle, the passengers walk to the wrong positions.
  • Passengers wait to the right of each bay, 3.76 m from its center line. Passengers who leave the bus stand 4.18 m from the center line. Put the curb or sidewalk there.
  • The heights are fixed world values for the flat example road. The road is at Y −0.002 m and the curb is at Y 0.215 m. On a slope or a road at another height, the passengers float or sink.
  • Waiting passengers farther than 55 m from the bus are hidden.
  • The script reads the vehicle once, when Play starts. If you assign a different vehicle later, the passengers are hidden and the route uses the plain dwell.
  • If a rear door becomes loose or detaches after a collision, the script stops moving that door. The stop then ends after the plain dwell. The passengers move between the curb and the seats without walking. RETRY does not repair the doors. Restart Play Mode to restore them.

If a requirement is missing, the script logs a warning that starts with Minibus Sample Boarding on 'Route Boarding': and switches itself off. The route uses the plain dwell and still adds the configured passenger count. Passenger models stay hidden.

The passenger models and the Idle and Walk clips are by Quaternius under CC0 1.0. See Samples/Market Passengers/Third-Party Notices.txt.

Comfort calculation

Route states
Points lost for each acceleration value

The score starts at 100 and can fall to 0. At each physics step, the challenge measures how quickly speed along the vehicle's horizontal forward axis changes. The measurement uses speed magnitude, so the rule also applies in reverse. A low-pass filter with a 0.35-second time constant smooths the measurement.

Acceleration above 1.5 m/s² and braking above 1.8 m/s² reduce the score. Each second spent 1 m/s² above either limit costs 7 points. Both thresholds are configurable. Lateral acceleration, vertical movement and stationary boarding contribute no direct penalty. A position discontinuity or replay clears the acceleration sample and boarding dwell.

Script reference

Add using BoneCrackerGames; and using BoneCrackerGames.DrivingSandbox.MinibusRoute; to your script.

The challenge works with the HUD disabled.

Member Purpose
MinibusRouteChallenge.Vehicle Gets or sets the vehicle. Assigning a different vehicle clears progress and captures its retry pose.
MinibusRouteChallenge.State Unavailable, Approach, AlignForward, StopVehicle, Boarding or Complete.
MinibusRouteChallenge.CurrentStop The next stop to serve. It is null after the last stop.
MinibusRouteChallenge.StopCount The number of stops in Stops.
MinibusRouteChallenge.StopsServed The number of stops served in this attempt.
MinibusRouteChallenge.PassengersBoarded The passengers boarded in this attempt.
MinibusRouteChallenge.DwellSeconds The continuous time in seconds that the vehicle meets all boarding conditions at the current stop.
MinibusRouteChallenge.DwellDuration The time in seconds that the current stop needs.
MinibusRouteChallenge.ComfortScore The comfort score from 0 to 100.
MinibusRouteChallenge.FilteredAcceleration The smoothed change of forward speed in m/s². Negative values are braking.
MinibusRouteChallenge.IsComplete True after the last stop.
MinibusRouteChallenge.OnRouteCompleted Runs once after the final stop. The final results are available. Connect it to your results screen or game mode.
MinibusRouteChallenge.ResetRoute() Clears progress and comfort without moving the vehicle.
MinibusRouteChallenge.Retry() In Play Mode, moves the vehicle to Retry Point or to its captured pose through RCCP, then calls ResetRoute(). It does nothing during a replay.
MinibusRouteStop.StopName Stop Name, or the GameObject name when Stop Name is blank.
MinibusRouteStop.Passengers The passengers who board at this stop.

Troubleshooting

Symptom Cause Fix
Another vehicle responds to the keys. Register Last Vehicle As Player is on, or Active Player Vehicle points to another vehicle. Assign your vehicle to Active Player Vehicle. Clear Register Last Vehicle As Player.
The HUD shows ASSIGN THE CHALLENGE ON THIS HUD. Challenge on the HUD is empty. Drag the Minibus Route Challenge object from the Hierarchy to Challenge.
The HUD shows ROUTE UNAVAILABLE. The vehicle is missing or inactive. Or Stops has an empty or repeated element, or the next stop is disabled. Enable the vehicle and the next stop. Assign the vehicle and each stop once. Read any Console warning from Minibus Route Challenge.
The bus is in the bay, but the HUD still shows NEXT STOP. Part of the vehicle footprint is outside the bay volume. Park farther inside the yellow rectangle. In your scene, increase the bay Size or correct Vehicle Footprint.
No passengers appear, and each stop ends after a short dwell. The sample boarding script switched itself off. Read the Console warning from Minibus Sample Boarding. See Sample boarding.
Passengers stay at the curb, then appear in their seats. A rear door is loose or detached after a collision. Restart Play Mode to restore the doors.
RETRY and INFO do nothing. The EventSystem or its Input System UI Input Module is missing. Add the missing object or component.