Libraries

s&box libraries

Wheel Collider

facepunch.libwheel

No summary provided.

About

Wheel Collider

Collider for ground vehicles, with built-in collision detection, basic suspension physics, and a basic tire friction model.

Usage

Create a car GameObject with a Rigidbody component, a collider, and a model.

Create four empty child GameObjects with just models. These shouldn't have colliders or be rigidbodies.

Attach a Component script that controls the car on the car GameObject, for example:

public sealed class Car : Component
{
[RequireComponent] public Rigidbody Rigidbody { get; set; }

private List<Wheel> Wheels;

protected override void OnEnabled()
{
Wheels = Components.GetAll<Wheel>( FindMode.EverythingInSelfAndDescendants ).ToList();
}

protected override void OnFixedUpdate()
{
float verticalInput = Input.AnalogMove.x;
float torque = verticalInput * 10000f;

// Apply torque to each drive wheel
foreach ( Wheel wheel in Wheels )
{
wheel.ApplyMotorTorque( torque );
}
}
}

More by Facepunch

01
Player Controller thumbnail
Player Controller facepunch.playercontroller

Components for player controller

playercontrollerfirstpersonshooterhalflifequake
+0 24h
98favorites
74upvotes
95%Wilson score
02
SDF Mesh Library thumbnail
SDF Mesh Library facepunch.libsdf

Marching cubes & squares mesh generation

procgenmesh3d2d
+0 24h
28favorites
24upvotes
86%Wilson score
03
Sprite Tools (OBSOLETE) thumbnail
Sprite Tools (OBSOLETE) facepunch.spritetools

Do not use anymore, SpriteRenderer and Sprite Resource are built-in now.

2dartpixelspritetools
+0 24h
19favorites
22upvotes
79%Wilson score
04
Game Events thumbnail
Game Events facepunch.libevents

Strongly typed game events

eventeventsfsm
+0 24h
15favorites
13upvotes
77%Wilson score
05
State Machines thumbnail
State Machines facepunch.libstates

State machines using Action Graph.

fsmstatesactiongraphstatemachine
+0 24h
11favorites
14upvotes
78%Wilson score
06
Spline Tools thumbnail
Spline Tools facepunch.splinetools

Work In Progress Spline Tools.

+0 24h
10favorites
17upvotes
82%Wilson score