How to create a Motorcycle Controller
Vehicle First Steps
1- Place motorcycle model in the scene, set layer of car to Vehicle(8) and Unpack Prefab
2- Add Colliders and Rigidbody (set a high value for the mass of the vehicle, like 100)
3- Create Wheel Colliders for each wheel model
4- Add Motorcycle Controller component and assign wheel models and wheel colliders in same sequence:
5- Assign Steering Wheel
6- Set the Center of Mass
7- Create a vehicle enter trigger
8- Create and assign Inverse Kinematic Target Positions
Tip: if you place the center of mass at the height of the wheels and further back, as in the image above, you will get good results
Motorcycle Parameters
Motorbike physics has some unique parameters:
Max Steer Angle
The max wheel steer angle
Throttle intensity
Wheel acceleration influence by the engine.
Brake Intensity
The brake force intensity influence by the engine settings.
Wheel Collider
The wheel collider.
Wheel mesh
The wheel model.
Sensitive
The sensitive to start lean on curves.
Speed
The speed to lean the motorcycle in curves.
Max Angle
Maximum angle the motorcycle can lean in motion.
Stopped Inclination
The angle of the wheel when stopped, used to simulate the driver's feet on ground.
On Grounded Drag
Motorcycle drag when on ground.
Off Ground Drag
Motorcycle drag when not grounded.
Enable Looping
Enable loop system
Loop Tag
Loop tag.
⚠ when the bike passes through an object with this tag the motorcycle lean system will be turned off to complete the loop correctly
Align With Loop Speed
The speed to align the Up with the loop normal.
Overturn Check is the same for any vehicle.
Motorcycle Suspension
Up to this point the bike will be working normally, however it is interesting to use a suspension script:
Result
Last updated