|
SleakEngine 1.0.0
C++23 multi-backend game engine
|
#include <FirstPersonController.hpp>
Public Member Functions | |
| FirstPersonController (GameObject *object) | |
| ~FirstPersonController () override | |
| float | GetJumpZVelocity () const |
| float | GetMaxFlySpeed () const |
| float | GetMaxWalkSpeed () const |
| float | GetPitch () const |
| float | GetSprintSpeedMultiplier () const |
| float | GetYaw () const |
| bool | Initialize () override |
| Grabs the sibling RigidbodyComponent and derives initial yaw/pitch from the camera's facing. | |
| bool | IsFlying () const |
| void | OnKeyPressed (const Events::Input::KeyPressedEvent &e) |
| Updates translation/sprint input state from a key-down event. | |
| void | OnKeyReleased (const Events::Input::KeyReleasedEvent &e) |
| Clears translation/sprint input state from a key-up event. | |
| void | SetAirControl (float airControl) |
| void | SetBrakingDeceleration (float decel) |
| void | SetEnabled (bool enabled) override |
| Toggles relative mouse mode and, when re-enabling, resets velocity and re-syncs yaw/pitch. | |
| void | SetFlying (bool flying) |
| Switches between grounded movement and free-flight, resetting vertical velocity. | |
| void | SetFlySprintMultiplier (float mult) |
| void | SetGroundFriction (float friction) |
| void | SetJumpZVelocity (float vel) |
| void | SetMaxAcceleration (float accel) |
| void | SetMaxFlySpeed (float speed) |
| void | SetMaxWalkSpeed (float speed) |
| void | SetPitch (float pitch) |
| void | SetSprintSpeedMultiplier (float mult) |
| void | SetVerticalFlyInput (float v) |
| void | SetYaw (float yaw) |
| void | ToggleCursor (bool enable) override |
| Shows or hides the OS cursor and, typically, toggles relative mouse mode. | |
| void | Update (float deltaTime) override |
| Public Member Functions inherited from Sleak::CameraController | |
| CameraController (GameObject *object) | |
| ~CameraController () override=default | |
| Camera * | GetCamera () |
| Casts the owning GameObject to Camera; valid only when attached to one. | |
| virtual float | GetSensitivity () const |
| virtual bool | IsEnabled () const |
| virtual void | SetSensitivity (float sensitivity) |
| Public Member Functions inherited from Sleak::Component | |
| Component (GameObject *object) | |
| virtual | ~Component ()=default |
| virtual void | FixedUpdate (float fixedDeltaTime) |
| GameObject * | GetOwner () |
| virtual void | LateUpdate (float deltaTime) |
| virtual void | OnDestroy () |
| Called when the component is detached or the owner is destroyed. | |
| virtual void | OnDisable () |
| virtual void | OnEnable () |
| Public Member Functions inherited from Sleak::Object | |
| Object (const std::string &name="Object") | |
| virtual | ~Object ()=default |
| const std::string & | GetName () const |
| uint64_t | GetUniqueID () const |
| void | SetName (const std::string &value) |
Additional Inherited Members | |
| Protected Attributes inherited from Sleak::CameraController | |
| Camera * | camera = nullptr |
| bool | isEnabled = true |
| Math::Vector2D | LastMousePosition |
| Math::Vector2D | MousePosition |
| Math::Vector3D | rotationInput |
| float | sensitivity = 0.0f |
| Math::Vector3D | translationInput |
| Protected Attributes inherited from Sleak::Component | |
| bool | bIsInitialized |
| GameObject * | owner |
Grounded first-person character controller with mouse look, jumping, sprinting, and an optional flight mode.
Attach it to a Camera to get a player you can walk around with. Movement follows Unreal's CharacterMovementComponent model: acceleration toward a target speed, braking deceleration and ground friction when input stops, and deliberately low air control so a jump commits to its arc. W, A, S, D translate, the mouse looks, and pitch is clamped to plus or minus 89 degrees.
It needs a sibling RigidbodyComponent, which Initialize() looks up: the rigidbody owns vertical motion and gravity, the controller owns horizontal velocity. Add a ColliderComponent too, or the character falls through the world.
SetEnabled(false) releases the mouse and stops all input handling, which is what you want when a menu or console opens. Re-enabling resets velocity and re-syncs yaw and pitch to the camera's current facing, so the view does not snap. SetFlying(true) switches to noclip-style free flight, driven by SetVerticalFlyInput() for up and down.
Definition at line 66 of file FirstPersonController.hpp.
| Sleak::FirstPersonController::FirstPersonController | ( | GameObject * | object | ) |
Definition at line 13 of file FirstPersonController.cpp.
|
override |
Definition at line 23 of file FirstPersonController.cpp.
|
inline |
Definition at line 84 of file FirstPersonController.hpp.
|
inline |
Definition at line 95 of file FirstPersonController.hpp.
|
inline |
Definition at line 80 of file FirstPersonController.hpp.
|
inline |
Definition at line 99 of file FirstPersonController.hpp.
|
inline |
Definition at line 82 of file FirstPersonController.hpp.
|
inline |
Definition at line 100 of file FirstPersonController.hpp.
|
overridevirtual |
Grabs the sibling RigidbodyComponent and derives initial yaw/pitch from the camera's facing.
Reimplemented from Sleak::CameraController.
Definition at line 28 of file FirstPersonController.cpp.
|
inline |
Definition at line 93 of file FirstPersonController.hpp.
| void Sleak::FirstPersonController::OnKeyPressed | ( | const Events::Input::KeyPressedEvent & | e | ) |
Updates translation/sprint input state from a key-down event.
Definition at line 191 of file FirstPersonController.cpp.
| void Sleak::FirstPersonController::OnKeyReleased | ( | const Events::Input::KeyReleasedEvent & | e | ) |
Clears translation/sprint input state from a key-up event.
Definition at line 212 of file FirstPersonController.cpp.
|
inline |
Definition at line 88 of file FirstPersonController.hpp.
|
inline |
Definition at line 86 of file FirstPersonController.hpp.
|
overridevirtual |
Toggles relative mouse mode and, when re-enabling, resets velocity and re-syncs yaw/pitch.
Reimplemented from Sleak::CameraController.
Definition at line 239 of file FirstPersonController.cpp.
| void Sleak::FirstPersonController::SetFlying | ( | bool | flying | ) |
Switches between grounded movement and free-flight, resetting vertical velocity.
Definition at line 231 of file FirstPersonController.cpp.
|
inline |
Definition at line 96 of file FirstPersonController.hpp.
|
inline |
Definition at line 87 of file FirstPersonController.hpp.
|
inline |
Definition at line 83 of file FirstPersonController.hpp.
|
inline |
Definition at line 85 of file FirstPersonController.hpp.
|
inline |
Definition at line 94 of file FirstPersonController.hpp.
|
inline |
Definition at line 79 of file FirstPersonController.hpp.
|
inline |
Definition at line 101 of file FirstPersonController.hpp.
|
inline |
Definition at line 81 of file FirstPersonController.hpp.
|
inline |
Definition at line 97 of file FirstPersonController.hpp.
|
inline |
Definition at line 102 of file FirstPersonController.hpp.
|
overridevirtual |
Shows or hides the OS cursor and, typically, toggles relative mouse mode.
Implements Sleak::CameraController.
Definition at line 53 of file FirstPersonController.cpp.
|
overridevirtual |
Implements Sleak::CameraController.
Definition at line 46 of file FirstPersonController.cpp.