reckfellENGINE

VehicleBody3D

A 3D physics body that simulates the behavior of a car.

On this page
class VehicleBody3DReckfellSharpInherits RigidBody3D

A 3D physics body that simulates the behavior of a car.

This physics body implements all the physics logic needed to simulate a car. It is based on the raycast vehicle system commonly found in physics engines. Aside from a CollisionShape3D for the main body of the vehicle, you must also add a VehicleWheel3D node for each wheel. You should also add a MeshInstance3D to this node for the 3D model of the vehicle, but this model should generally not include meshes for the wheels. You can control the vehicle by using the VehicleBody3D.Brake, VehicleBody3D.EngineForce, and VehicleBody3D.Steering properties. The position or orientation of this node shouldn't be changed directly. Note: The local forward for this node is Vector3.ModelFront. Note: The origin point of your VehicleBody3D will determine the center of gravity of your vehicle. To make the vehicle more grounded, the origin point is usually kept low, moving the CollisionShape3D and MeshInstance3D upwards. Note: This class has known issues and isn't designed to provide realistic 3D vehicle physics. If you want advanced vehicle physics, you may have to write your own physics integration using CharacterBody3D or RigidBody3D.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

VehicleBody3DConstructor
# VehicleBody3D
C#
public VehicleBody3D();

Properties3

BrakeProperty
# Brake
C#
public float Brake { get; set; }

Slows down the vehicle by applying a braking force. The vehicle is only slowed down if the wheels are in contact with a surface. The force you need to apply to adequately slow down your vehicle depends on the RigidBody3D.Mass of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking.

EngineForceProperty
# EngineForce
C#
public float EngineForce { get; set; }

Accelerates the vehicle by applying an engine force. The vehicle is only sped up if the wheels that have VehicleWheel3D.UseAsTraction set to true and are in contact with a surface. The RigidBody3D.Mass of the vehicle has an effect on the acceleration of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 50 range for acceleration. Note: The simulation does not take the effect of gears into account, you will need to add logic for this if you wish to simulate gears. A negative value will result in the vehicle reversing.

SteeringProperty
# Steering
C#
public float Steering { get; set; }

The steering angle for the vehicle. Setting this to a non-zero value will result in the vehicle turning when it's moving. Wheels that have VehicleWheel3D.UseAsSteering set to true will automatically be rotated. Note: This property is edited in the inspector in degrees. In code the property is set in radians.

Methods6

GetBrakefloat
# GetBrake
C#
public float GetBrake();
Returns float
GetEngineForcefloat
# GetEngineForce
C#
public float GetEngineForce();
Returns float
GetSteeringfloat
# GetSteering
C#
public float GetSteering();
Returns float
SetBrakevoid
# SetBrake
C#
public void SetBrake(float brake);
Parameters
NameTypeDefault
brakefloat—
SetEngineForcevoid
# SetEngineForce
C#
public void SetEngineForce(float engineForce);
Parameters
NameTypeDefault
engineForcefloat—
SetSteeringvoid
# SetSteering
C#
public void SetSteering(float steering);
Parameters
NameTypeDefault
steeringfloat—
Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.