custom 3d car
For this Godot project, I built a custom vehicle simulation from the ground up, combining high-performance physics with an extensive, interactive driving model designed to deliver a highly customizable and engaging driving experience.
The simulation leverages the Jolt Physics engine for robust RigidBody3D dynamics, combined with a custom-engineered Wheel class. Using RayCast3D nodes for precise ground detection, each wheel calculates independent suspension, acceleration, steering, speed-sensitive lateral grip, and multi-tier rolling friction.
detailed wheel simulation
Each wheel is individually simulated to provide authentic, responsive car behavior:
- Suspension: A highly configurable spring and damper system dynamically calculates spring compression forces and damper resistance based on rest height and wheel travel, ensuring stable handling over bumps and uneven terrain.
- Traction & Steering: Tailored steering angles and acceleration forces are applied directly at each wheel's contact point, allowing for precise control and dynamic, high-speed maneuvers.
- Friction & Drift: Both rolling and lateral friction are simulated. The lateral physics incorporates a speed-dependent grip falloff that models realistic tire slip at high speeds, while rolling resistance dynamically scales when applying the brakes or pulling the handbrake.
advanced transmission & nitro boost
To enhance the driving dynamics, the vehicle simulates mechanical drivetrain components and a nitrous injection system:
- Engine & Transmission: Features a fully modeled automatic and manual gearbox supporting 6 forward gears, neutral, and reverse with custom ratios. The engine RPM is calculated dynamically from wheel speed and a final drive ratio, featuring realistic shift thresholds and an active rev-limiter that cuts power when hitting the redline.
- Nitro Boost: A dynamic nitrous oxide system applies strong longitudinal thrust for high-speed acceleration. It features active fuel consumption and a cooling/refilling delay that replenishes the boost when not in use.
dynamic camera, lighting & audio
The visual and auditory atmosphere is fully interactive, reacting in real-time to driving inputs:
- Orbiting SpringArm Camera: Intelligently orbits the car using a collision-aware SpringArm3D. Players can orbit the camera with the mouse or let the system auto-rotate and snap to the vehicle's heading direction during movement.
- Interactive Lighting: Normal headlights and highbeams can be toggled manually, utilizing smooth tweened spot ranges. Additionally, rear brake lights automatically glow when decelerating or reversing.
- Adaptive Sound Effects: The audio landscape adapts to the car's state: the engine loop pitch scales dynamically with engine RPM and throttle input, manual handbrake pulls and headlight switches trigger physical clicks, and collision sounds dynamically scale in intensity based on light, medium, or hard impact velocities.
This comprehensive vehicle system was key to achieving a responsive and detailed driving experience, offering precise control over every nuance of the car's behavior.