Nox Engine
 
Loading...
Searching...
No Matches
Collider Struct Reference

Provides an entity with a physical bounding box for collision detection. More...

#include <Collider.h>

Inheritance diagram for Collider:
Inheritance graph
Collaboration diagram for Collider:
Collaboration graph

Public Member Functions

 Collider (std::string tag, std::function< void(Collider &other)> onCollision, bool isTrigger=false, bool isStatic=false, bool considerVel=false, bool isUi=false)
 Constructs a fully configured Collider.
 
 Collider (std::string tag)
 Constructs a simple Collider with only a tag.
 
void init () override
 Initializes the collider by linking it to the entity's transform.
 
void update () override
 Updates the collider's position and checks for collisions against other colliders.
 
void onCollision (Collider &other)
 Executes the collision callback function.
 
const bool isColliding (std::string collTag)
 Checks if this collider is currently colliding with any collider of a specific tag.
 
- Public Member Functions inherited from Component
virtual void reload ()
 Called to reset the component's state.
 
virtual void draw ()
 Called once per frame after update. Used for rendering.
 

Public Attributes

std::string tag
 A tag to identify the type of collider (e.g., "player", "wall").
 
- Public Attributes inherited from Component
Entityentity
 Pointer to the entity that owns this component.
 

Detailed Description

Provides an entity with a physical bounding box for collision detection.

Can function as a solid object, a trigger volume, or a static body. Executes a callback function upon collision with another collider.

Constructor & Destructor Documentation

◆ Collider() [1/2]

Collider::Collider ( std::string  tag,
std::function< void(Collider &other)>  onCollision,
bool  isTrigger = false,
bool  isStatic = false,
bool  considerVel = false,
bool  isUi = false 
)

Constructs a fully configured Collider.

Parameters
tagIdentifier for this collider type.
onCollisionCallback function executed on collision.
isTriggerIf true, detects collisions but does not cause a physical response.
isStaticIf true, the collider is considered immovable.
considerVelIf true, includes velocity in collision checks for better tunneling prevention.
isUiIf true, indicates this is a UI element collider.
Here is the call graph for this function:

◆ Collider() [2/2]

Collider::Collider ( std::string  tag)

Constructs a simple Collider with only a tag.

Parameters
tagIdentifier for this collider type.
Here is the call graph for this function:

Member Function Documentation

◆ init()

void Collider::init ( )
overridevirtual

Initializes the collider by linking it to the entity's transform.

Reimplemented from Component.

Here is the call graph for this function:

◆ isColliding()

const bool Collider::isColliding ( std::string  collTag)

Checks if this collider is currently colliding with any collider of a specific tag.

Parameters
collTagThe tag to check for collision against.
Returns
True if a collision is occurring, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ onCollision()

void Collider::onCollision ( Collider other)

Executes the collision callback function.

Parameters
otherThe Collider component of the other entity involved in the collision.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

void Collider::update ( )
overridevirtual

Updates the collider's position and checks for collisions against other colliders.

Reimplemented from Component.

Here is the call graph for this function:

The documentation for this struct was generated from the following files: