Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
VehicleController.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm>
4
5namespace Physics::Component {
6
16 float forwardInput = 0.0f;
17
19 float steeringInput = 0.0f;
20
22 float brakeInput = 0.0f;
23
25 float handBrakeInput = 0.0f;
26
31 void SetForward(float value) { forwardInput = std::clamp(value, -1.0f, 1.0f); }
32
37 void SetSteering(float value) { steeringInput = std::clamp(value, -1.0f, 1.0f); }
38
43 void SetBrake(float value) { brakeInput = std::clamp(value, 0.0f, 1.0f); }
44
49 void SetHandBrake(float value) { handBrakeInput = std::clamp(value, 0.0f, 1.0f); }
50
55 {
56 forwardInput = 0.0f;
57 steeringInput = 0.0f;
58 brakeInput = 0.0f;
59 handBrakeInput = 0.0f;
60 }
61};
62
63} // namespace Physics::Component
Definition BoxCollider.hpp:27
Vehicle input controller component.
Definition VehicleController.hpp:14
void SetSteering(float value)
Set steering input.
Definition VehicleController.hpp:37
float brakeInput
Brake input (0.0 = no brake, 1.0 = full brake).
Definition VehicleController.hpp:22
void ResetInputs()
Reset all inputs to neutral.
Definition VehicleController.hpp:54
float forwardInput
Forward/backward input (-1.0 = full brake/reverse, 0.0 = neutral, 1.0 = full throttle).
Definition VehicleController.hpp:16
float steeringInput
Steering input (-1.0 = full left, 0.0 = straight, 1.0 = full right).
Definition VehicleController.hpp:19
void SetForward(float value)
Set forward/backward input.
Definition VehicleController.hpp:31
void SetBrake(float value)
Set brake input.
Definition VehicleController.hpp:43
void SetHandBrake(float value)
Set handbrake input.
Definition VehicleController.hpp:49
float handBrakeInput
Handbrake input (0.0 = off, 1.0 = full handbrake).
Definition VehicleController.hpp:25