Add NavCrowd initialization with specific NavAgentProperties to pick a proper navmesh automatically

This commit is contained in:
Wojtek Figat
2022-06-26 15:53:51 +02:00
parent 982accde6d
commit 5fdd8a4b72
2 changed files with 14 additions and 0 deletions

View File

@@ -23,6 +23,12 @@ bool NavCrowd::Init(float maxAgentRadius, int32 maxAgents, NavMesh* navMesh)
return Init(maxAgentRadius, maxAgents, navMeshRuntime);
}
bool NavCrowd::Init(const NavAgentProperties& agentProperties, int32 maxAgents)
{
NavMeshRuntime* navMeshRuntime = NavMeshRuntime::Get(agentProperties);
return Init(agentProperties.Radius * 3.0f, maxAgents, navMeshRuntime);
}
bool NavCrowd::Init(float maxAgentRadius, int32 maxAgents, NavMeshRuntime* navMesh)
{
if (!_crowd || !navMesh)

View File

@@ -31,6 +31,14 @@ public:
/// <returns>True if failed, otherwise false.</returns>
API_FUNCTION() bool Init(float maxAgentRadius = 100.0f, int32 maxAgents = 25, NavMesh* navMesh = nullptr);
/// <summary>
/// Initializes the crowd.
/// </summary>
/// <param name="agentProperties">The properties of the agents that will be added to the crowd.</param>
/// <param name="maxAgents"> maximum number of agents the crowd can manage.</param>
/// <returns>True if failed, otherwise false.</returns>
API_FUNCTION() bool Init(const NavAgentProperties& agentProperties, int32 maxAgents = 25);
/// <summary>
/// Initializes the crowd.
/// </summary>