Add setter for crword agent position and velocity
This commit is contained in:
@@ -104,6 +104,15 @@ Vector3 NavCrowd::GetAgentPosition(int32 id) const
|
||||
return result;
|
||||
}
|
||||
|
||||
void NavCrowd::SetAgentPosition(int32 id, const Vector3& position)
|
||||
{
|
||||
dtCrowdAgent* agent = _crowd->getEditableAgent(id);
|
||||
if (agent)
|
||||
{
|
||||
*(Float3*)agent->npos = Float3(position);
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 NavCrowd::GetAgentVelocity(int32 id) const
|
||||
{
|
||||
Vector3 result = Vector3::Zero;
|
||||
@@ -115,6 +124,15 @@ Vector3 NavCrowd::GetAgentVelocity(int32 id) const
|
||||
return result;
|
||||
}
|
||||
|
||||
void NavCrowd::SetAgentVelocity(int32 id, const Vector3& velocity)
|
||||
{
|
||||
dtCrowdAgent* agent = _crowd->getEditableAgent(id);
|
||||
if (agent)
|
||||
{
|
||||
*(Float3*)agent->nvel = Float3(velocity);
|
||||
}
|
||||
}
|
||||
|
||||
void NavCrowd::SetAgentProperties(int32 id, const NavAgentProperties& properties)
|
||||
{
|
||||
dtCrowdAgentParams agentParams;
|
||||
|
||||
@@ -63,6 +63,13 @@ public:
|
||||
/// <returns>The agent current position.</returns>
|
||||
API_FUNCTION() Vector3 GetAgentPosition(int32 id) const;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the agent current position.
|
||||
/// </summary>
|
||||
/// <param name="id">The agent ID.</param>
|
||||
/// <param name="position">The agent position.</param>
|
||||
API_FUNCTION() void SetAgentPosition(int32 id, const Vector3& position);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the agent current velocity (direction * speed).
|
||||
/// </summary>
|
||||
@@ -70,6 +77,13 @@ public:
|
||||
/// <returns>The agent current velocity (direction * speed).</returns>
|
||||
API_FUNCTION() Vector3 GetAgentVelocity(int32 id) const;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the agent current velocity (direction * speed).
|
||||
/// </summary>
|
||||
/// <param name="id">The agent ID.</param>
|
||||
/// <param name="position">The agent velocity (direction * speed).</param>
|
||||
API_FUNCTION() void SetAgentVelocity(int32 id, const Vector3& velocity);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the agent properties.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user