Clutter Engine 0.0.1
|
PlayerController2D class responsible for handling 2D player movements and collisions.
More...
#include <PlayerController2D.h>
Public Member Functions | |
PlayerController2D (std::string pMovementCallback, std::string pJumpCallback="", float pSpeed=2) | |
Constructor for PlayerController2D. | |
~PlayerController2D ()=default | |
Destructor for PlayerController2D. | |
virtual void | Movement (Vector2 pDirection) |
Handles player movement in a given direction using a vector. | |
virtual void | Movement (float pDirection) |
Handles player movement in a given direction using a scalar. | |
virtual void | Update () override |
Updates the player controller every frame. | |
virtual void | Jump () |
Handles player jump action. | |
virtual void | SetOwner (Actor *pOwner) override |
Sets the owner actor for this component. | |
virtual void | OnCollisionEnter (ColliderComponent *collider, const hitResult &result) override |
Called when a collision starts. | |
virtual void | OnCollisionStay (ColliderComponent *collider, const hitResult &result) override |
Called when a collision stays. | |
virtual void | OnCollisionExit (ColliderComponent *collider, const hitResult &result) override |
Called when a collision ends. | |
![]() | |
PlayerController (float pSpeed=2) | |
Constructs a PlayerController with an optional movement speed. | |
~PlayerController ()=default | |
Default destructor. | |
virtual void | OnTriggerEnter (ColliderComponent *collider, const hitResult &result) override |
Called when a trigger is entered. | |
virtual void | OnTriggerStay (ColliderComponent *collider, const hitResult &result) override |
Called while inside a trigger. | |
virtual void | OnTriggerExit (ColliderComponent *collider, const hitResult &result) override |
Called when exiting a trigger. | |
![]() | |
Component (int pUpdateOrder=0) | |
Constructor for Component. | |
virtual | ~Component ()=default |
Virtual destructor for Component. | |
virtual void | Start () |
Called when the component is started. | |
virtual void | Destroy () |
Called to destroy the component. | |
void | SetActive (bool pActive) |
Enables or disables the component. | |
void | OnDestroy () |
Called when the component is destroyed. | |
bool | IsActive () const |
Checks if the component is enabled. | |
int | GetUpdateOrder () const |
Gets the update order of the component. | |
void | SetRelativeLocation (const Vector3 &loc) |
Sets the relative location of the component. | |
void | SetRelativeLocation (const Vector2 &loc) |
Sets the relative location of the component. | |
void | SetWorldLocation (const Vector3 &loc) |
Sets the world location of the component. | |
void | SetRelativeScale (const Vector3 &scale) |
Sets the relative scale of the component. | |
void | SetRelativeScale (const Vector2 &scale) |
Sets the relative scale of the component. | |
void | SetRelativeRotation (Quaternion rot) |
Sets the relative rotation of the component. | |
void | SetRelativeRotation (Vector3 rot) |
Sets the relative rotation of the component. | |
void | SetWorldRotation (const Quaternion &rot) |
Sets the world rotation of the component. | |
void | SetWorldRotation (const Vector3 &rot) |
Sets the world rotation of the component. | |
void | AddRelativeRotation (Vector3 rot) |
Adds a rotation to the current relative rotation. | |
void | SetRelativeRotation (float rot) |
Sets the relative rotation of the component. | |
void | SetRelativeTransform (Transform &transform) |
Sets the relative transform of the component. | |
Vector3 | GetRelativeLocation () const |
Gets the relative location of the component. | |
Vector3 | GetRelativeScale () const |
Gets the relative scale of the component. | |
Quaternion | GetRelativeRotation () const |
Gets the relative rotation of the component. | |
Vector3 | GetRelativeRotationEuler () const |
Gets the relative rotation of the component as Euler angles. | |
Transform | GetRelativeTransform () const |
Gets the relative transform of the component. | |
Vector3 | GetWorldLocation () const |
Gets the world location of the component. | |
Vector3 | GetWorldScale () const |
Gets the world scale of the component. | |
Quaternion | GetWorldRotation () const |
Gets the world rotation of the component. | |
virtual Transform | GetWorldTransform () const |
Gets the world transform of the component. | |
Actor * | GetOwner () const |
Gets the owner actor of this component. | |
![]() | |
virtual | ~ICollisionListener ()=default |
Virtual destructor for safe polymorphic destruction. | |
Additional Inherited Members | |
![]() | |
MovementMode | mMovement |
Current movement mode of the player. | |
bool | mIsJumping |
True if the player is currently jumping. | |
bool | mIsMoving |
True if the player is currently moving. | |
bool | mIsSprinting |
True if the player is currently sprinting. | |
bool | mIsCrouched |
True if the player is currently crouched. | |
float | mJumpHeight |
The height the player can jump. | |
int | mJumpAmount |
The number of jumps the player can perform. | |
float | mMaxWalkSpeed |
The maximum walking speed. | |
float | mMaxSprintSpeed |
The maximum sprinting speed. | |
float | mMaxAcceleration |
The maximum acceleration of the player. | |
float | mAirControl |
The amount of control the player has while in the air. | |
Vector2 | mMouseSpeed |
The speed of the mouse input. | |
![]() | |
friend | Actor |
![]() | |
bool | LineTrace (Vector3 start, Vector3 direction, float maxDistance, raycastHit &hit, bool debugPersistant=false) |
Performs a line trace (raycast) using the owning actor. | |
![]() | |
bool | mIsActive = true |
Indicates if the component is active. | |
int | mUpdateOrder = 0 |
The order in which the component is updated. | |
Actor * | mOwner |
The actor that owns this component. | |
Transform | mRelativeTransform |
The relative transform of the component to its owner. | |
PlayerController2D class responsible for handling 2D player movements and collisions.
This component manages player movement, jumping, and collision events for 2D games.
It interacts with the player's sprite and rigid body components to provide movement and physics behavior.
PlayerController2D::PlayerController2D | ( | std::string | pMovementCallback, |
std::string | pJumpCallback = "", | ||
float | pSpeed = 2 ) |
Constructor for PlayerController2D.
pMovementCallback | Name of the callback function for movement. |
pJumpCallback | Name of the callback function for jump (optional). |
pSpeed | Speed of the player (default is 2). |
|
virtual |
Handles player movement in a given direction using a scalar.
pDirection | The direction scalar for movement. |
|
virtual |
Handles player movement in a given direction using a vector.
pDirection | The direction vector for movement. |
|
overridevirtual |
Called when a collision starts.
collider | The collider component involved in the collision. |
result | The result of the collision. |
Reimplemented from clt::PlayerController.
|
overridevirtual |
Called when a collision ends.
collider | The collider component involved in the collision. |
result | The result of the collision. |
Reimplemented from clt::PlayerController.
|
overridevirtual |
Called when a collision stays.
collider | The collider component involved in the collision. |
result | The result of the collision. |
Reimplemented from clt::PlayerController.
|
overridevirtual |
Sets the owner actor for this component.
pOwner | Pointer to the owner actor. |
Reimplemented from clt::Component.
|
overridevirtual |
Updates the player controller every frame.
Reimplemented from clt::Component.