An enterprise-grade autonomous vehicle simulation and navigation controller engineered for constraint-based vehicles in the Roblox engine.
- Main Script:
AutonomousVehicleSystem.luau
- Constructed with Luau metatables (
__index) and strict static typing (--!strict). - Complete lifecycle management (
new,Start,Update,Destroy).
- Uses
CFrame:VectorToObjectSpaceto convert worldAssemblyLinearVelocityinto chassis-local axes, isolating longitudinal speed (-relativeVelocity.Z) and lateral drift. - Calculates target heading deviation in vehicle local space using
CFrame:PointToObjectSpaceandmath.atan2(localTarget.X, -localTarget.Z).
- Projects 3 predictive directional rays from the vehicle origin:
- Center Ray: Direct forward trajectory.
-
Left Ray: +28° yaw offset via
CFrame.Angles(0, math.rad(28), 0). -
Right Ray: -28° yaw offset via
CFrame.Angles(0, math.rad(-28), 0).
- Weighs repulsion bias inversely proportional to obstacle proximity (
$1 - \frac{\text{dist}}{\text{range}}$ ) to guide the steering rack away from barriers smoothly.
- Continuously calculates tire perimeter surface speed (
$v_{\text{surface}} = \omega \cdot r$ ) against partAssemblyLinearVelocity.Magnitude. - Dynamically assigns
PhysicalProperties.new(density, friction, elasticity)on wheel parts when slip exceeds thresholds, simulating transition between static rolling traction and kinetic skidding.
- Low-pass filters virtual engine RPM/speed to replicate drivetrain inertia.
- Torque interpolation curve delivering high low-end torque for static break-away force and tapered torque at maximum speed.
- Speed-sensitive steering reduction to prevent high-speed rollover instability.
-
Anti-Flip Recovery: Evaluates seat
CFrame.UpVector.Y. If tilted beyond recoverable threshold ($< 0.25$ ) for over 2 seconds, zeroes angular momentum and uprights the chassis. - Unstuck Routine: Monitors vehicle displacement under high commanded engine speed. Triggers a two-stage counter-steer and reverse throttle sequence when immobilized.
- Clone or download this repository.
- In Roblox Studio, place
AutonomousVehicleSystem.luauinside any constraint-based vehicle Model (requiringChassis,Enginewith 4 drive motors,SteeringwithSteeringRack, andWheelsfolder). - Optional: Add a
Waypointsfolder inWorkspacecontaining numbered parts to establish a cyclic patrol route.
- GitHub: @rdj415
- Roblox:
DiscoUnicorn478 - Discord:
rd_rb