Kemena3D
Loading...
Searching...
No Matches
kemena::kNavAgent Class Reference

A single crowd agent managed by kNavManager. More...

#include <knavagent.h>

Public Member Functions

 kNavAgent ()
 Constructs an uninitialised agent; call init() before use.
 ~kNavAgent ()
 Destroys the agent, releasing internal crowd resources.
bool setTarget (const kVec3 &target)
 Sets the movement target on the navmesh.
void stop ()
 Stops the agent in place.
kVec3 getPosition () const
 Current world-space position of the agent.
kVec3 getVelocity () const
 Current world-space velocity of the agent.
bool isMoving () const
 Returns true if the agent is actively moving toward a target.
bool isValid () const
 Returns true if this agent slot is active in the crowd.
void setMaxSpeed (float speed)
 Overrides the agent's maximum speed at runtime.
void setMaxAcceleration (float accel)
 Overrides the agent's maximum acceleration at runtime.
float getMaxSpeed () const
 Returns the agent's current maximum speed.
float getMaxAcceleration () const
 Returns the agent's current maximum acceleration.
bool init (void *crowd, void *navMeshQuery, const kVec3 &position, const kNavAgentConfig &config)
 Initialises the agent inside an existing dtCrowd.
void uninit ()
 Removes the agent from the crowd.
int getAgentIndex () const
 Returns the internal crowd agent index.

Detailed Description

A single crowd agent managed by kNavManager.

Do not create directly — obtain via kNavManager::addAgent(). The agent is driven by Detour Crowd each frame and moves toward its current target.

kNavAgent* agent = navManager->addAgent(spawnPos, config);
agent->setTarget(goalPos);
// each frame:
agent->getPosition(); // current smooth position
kVec3 getPosition() const
Current world-space position of the agent.
kNavAgent()
Constructs an uninitialised agent; call init() before use.
bool setTarget(const kVec3 &target)
Sets the movement target on the navmesh.

Constructor & Destructor Documentation

◆ kNavAgent()

kemena::kNavAgent::kNavAgent ( )

Constructs an uninitialised agent; call init() before use.

◆ ~kNavAgent()

kemena::kNavAgent::~kNavAgent ( )

Destroys the agent, releasing internal crowd resources.

Member Function Documentation

◆ getAgentIndex()

int kemena::kNavAgent::getAgentIndex ( ) const

Returns the internal crowd agent index.

Returns
Index of this agent within the dtCrowd, or -1 if inactive.

◆ getMaxAcceleration()

float kemena::kNavAgent::getMaxAcceleration ( ) const

Returns the agent's current maximum acceleration.

Returns
Maximum acceleration (m/s²).

◆ getMaxSpeed()

float kemena::kNavAgent::getMaxSpeed ( ) const

Returns the agent's current maximum speed.

Returns
Maximum speed (m/s).

◆ getPosition()

kVec3 kemena::kNavAgent::getPosition ( ) const

Current world-space position of the agent.

◆ getVelocity()

kVec3 kemena::kNavAgent::getVelocity ( ) const

Current world-space velocity of the agent.

◆ init()

bool kemena::kNavAgent::init ( void * crowd,
void * navMeshQuery,
const kVec3 & position,
const kNavAgentConfig & config )

Initialises the agent inside an existing dtCrowd.

Parameters
crowdOpaque pointer to the owning dtCrowd instance.
navMeshQueryOpaque pointer to the dtNavMeshQuery used for navigation.
positionInitial world-space spawn position of the agent.
configPer-agent parameters to apply on creation.
Returns
false if the agent could not be added to the crowd.

◆ isMoving()

bool kemena::kNavAgent::isMoving ( ) const

Returns true if the agent is actively moving toward a target.

◆ isValid()

bool kemena::kNavAgent::isValid ( ) const

Returns true if this agent slot is active in the crowd.

◆ setMaxAcceleration()

void kemena::kNavAgent::setMaxAcceleration ( float accel)

Overrides the agent's maximum acceleration at runtime.

Parameters
accelNew maximum acceleration (m/s²).

◆ setMaxSpeed()

void kemena::kNavAgent::setMaxSpeed ( float speed)

Overrides the agent's maximum speed at runtime.

Parameters
speedNew maximum speed (m/s).

◆ setTarget()

bool kemena::kNavAgent::setTarget ( const kVec3 & target)

Sets the movement target on the navmesh.

Parameters
targetDesired world-space goal position.
Returns
false if the target is off the navmesh or the agent is invalid.

◆ stop()

void kemena::kNavAgent::stop ( )

Stops the agent in place.

◆ uninit()

void kemena::kNavAgent::uninit ( )

Removes the agent from the crowd.


The documentation for this class was generated from the following file: