On this page
Module guide

Vehicle Inspection

Open and close four doors, the hood and the trunk on a parked RCCP 2 Sedan.

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-VehicleInspection.unitypackage, made with Export Module > Vehicle Inspection.

Installation order for Vehicle Inspection
  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-VehicleInspection.unitypackage.

Try the example

Vehicle Inspection at the start of Play Mode
No. Item
1 Part buttons
2 OPEN ALL and CLOSE ALL
3 CAMERA VIEW buttons
4 INFO button
5 Inspection Sedan
  1. Open Assets/RCCP 2 Driving Sandbox/Modules/VehicleInspection/Samples/Vehicle Inspection Example.unity.
  2. Enter Play Mode.
  3. Select a door, HOOD or TRUNK to open that part. Select the button again to close the part.
  4. Select OPEN ALL or CLOSE ALL to operate all six parts.
  5. Under CAMERA VIEW, select FRONT LEFT, FRONT RIGHT, REAR LEFT or REAR RIGHT to inspect another side of the vehicle.
Open one part, open all parts and change the view
The four camera views

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

The Info panel

The example scene disables driving with two scene overrides on the Inspection Sedan object:

  • Player can drive this car is off on the RCCP Car Controller.
  • Engine running at start is off on the RCCP Engine.

Prefabs/Inspection Sedan.prefab does not have these overrides. In another scene, the prefab is a drivable vehicle.

The Rigidbody has no frozen axes. Gravity and collisions remain active while you inspect the parts.

The example scene hides the seated driver. The reusable Inspection Sedan prefab keeps its driver.

Controls

The example has no driving keys. Use the mouse on the HUD.

Action Key
Open or close one part Select the door, HOOD or TRUNK button
Open or close all parts Select OPEN ALL or CLOSE ALL
Change the camera view Select a CAMERA VIEW button
Show the setup help Select INFO

Use it in your scene

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

The tool sets up the inspection camera, part controls and HUD. If you want to drive the vehicle, set up RCCP Scene Manager separately.

Check the joints of the supported parts. If the dialog reports a joint problem, follow manual steps 3 to 5 below. Adjust the four camera poses as necessary. To park the vehicle, clear Player can drive this car and Engine running at start. Disable Inspection Camera when the RCCP Camera must show the driving view. Complete any other steps in the setup dialog.

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

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

Before you start, put your vehicle on a level floor with a solid collider. To test the hinges, drag Prefabs/Inspection Sedan.prefab into the scene. Use a standard Unity camera for inspection. If you add a separate inspection camera, disable the original Main Camera.

  1. Select an RCCP 2 vehicle with working RCCP_DetachablePart hinges on its doors, hood or trunk.
  2. Select each part GameObject that you want to operate. Select Add Component > BoneCracker Games > Driving Sandbox > Vehicle Inspection > Vehicle Inspection Hinge. The part needs an RCCP_DetachablePart, a ConfigurableJoint and a Rigidbody.
  3. Enable Lock At Start on the detachable part.
  4. Set the angular X limits on its Configurable Joint. Include zero in the range and permit some travel. Clear Is Kinematic on the part Rigidbody.
  5. Keep angular Y and Z locked. Use a Connected Body and local joint space.
  6. Set Opening Fraction to the part of the available hinge travel you want to use.
  7. Add Prefabs/Vehicle Inspection HUD.prefab to the scene.
  8. Select the standard Unity camera. Select Add Component > BoneCracker Games > Driving Sandbox > Vehicle Inspection > Vehicle Inspection Camera. Create an empty GameObject for each camera pose. Turn each GameObject toward the vehicle.
  9. Assign the poses to Views in this order: Front left, Front right, Rear left, Rear right. This order matches the HUD labels.
  10. Connect the HUD buttons. See Connect the HUD buttons.
  11. If the scene has no EventSystem, select GameObject > UI > Event System. Use an Input System UI Input Module on the EventSystem.
  12. To disable driving, clear Player can drive this car and Engine running at start. Keep Rigidbody Constraints set to None.
Door_FL: 1 Lock At Start, 2 Opening Fraction. Inspection Camera: 1 Views
A selected door part in the Scene view

The HUD prefab, the hinge and the camera script are the reusable parts. The Inspection Sedan and the inspection bay are sample parts.

The hinge operates on an attached RCCP part with strength above its Loose Point. The inspection controls do not operate a loose or detached part. Plan enough clearance for each panel to move. Close the parts before you repair the vehicle.

Connect the HUD buttons

For a manual installation, connect the HUD buttons to the parts and camera.

From the button to the part
The On Click () entry of the Front left door button
  1. Select a part button under Vehicle Inspection HUD/Inspection Panel, for example Front left door.
  2. In On Click (), select +.
  3. Drag the part GameObject that has the hinge to the object field.
  4. Select VehicleInspectionHinge > Toggle ().
  5. Repeat steps 1 to 4 for Front right door, Rear left door, Rear right door, Hood and Trunk.
  6. On Open All, add one On Click () entry for each hinge. Select VehicleInspectionHinge > Open ().
  7. On Close All, add one On Click () entry for each hinge. Select VehicleInspectionHinge > Close ().
  8. On each Camera view button, drag the camera to the object field. Select VehicleInspectionCamera > ShowView (int).
  9. Enter the view index: 0 for Front left, 1 for Front right, 2 for Rear left and 3 for Rear right.

If your vehicle has fewer parts, delete the unused buttons.

Script reference

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

Member Purpose
VehicleInspectionHinge.Open() Opens the part if the RCCP part is attached and firm.
VehicleInspectionHinge.Close() Closes the part if the RCCP part is attached and firm.
VehicleInspectionHinge.Toggle() Reverses the current open or close request.
VehicleInspectionHinge.IsOpenRequested The latest request. It can change before the part settles.
VehicleInspectionHinge.CurrentAngle The measured angle in degrees from the closed position.
VehicleInspectionHinge.OpenAngle The open angle in degrees. Multiply Opening Fraction by the absolute value of the angular X limit farthest from zero.
VehicleInspectionCamera.ShowView(int) Moves the camera to the pose at that index in Views. The Console shows a warning if that view is missing.

The hinge unlocks the angular X motion of the joint and drives the part with a spring. The hinge locks the joint again when the part is within 0.5° of closed and almost stops.

Troubleshooting

Symptom Cause Fix
A button does nothing, and the Console shows no message. The button has no On Click () entry, or the scene has no EventSystem. Connect the button. See Connect the HUD buttons. Add an EventSystem.
The Console shows Vehicle Inspection Hinge on '<part>': the object needs an RCCP_DetachablePart, a ConfigurableJoint and a Rigidbody. The hinge is on an object that is not an RCCP hinged part. Move the hinge to the part GameObject that has the joint, or remove the hinge.
The Console shows Vehicle Inspection Hinge on '<part>': the Configurable Joint needs a Connected Body ... Connected Body is empty, Lock At Start is off, angular Y or Z is not locked, the part is kinematic, or the angular X limits are not valid. Do steps 3 to 5 of Use it in your scene.
A part stops moving after a collision. The part is loose or detached. Its strength is at or below Loose Point. Restart Play Mode.
A camera button does nothing, and the Console says Views has no Transform. The Views element for that button is missing. Assign a pose to the element named in the warning.
A camera button shows the wrong side of the vehicle. The order of Views does not match the HUD labels. Assign Views in the order Front left, Front right, Rear left, Rear right.
The vehicle rolls or accepts driving input in your scene. The parking settings are scene overrides in the example. Do step 12 of Use it in your scene. If the vehicle rolls, make the floor level.