/// <summary> /// Adds an agent to the manager. /// </summary> /// <param name="position"> /// The current position of the agent within the navigation mesh. /// </param> /// <param name="agentParams">The agent configuration.</param> /// <returns> /// A reference to the agent object created by the manager, or null on error. /// </returns> public CrowdAgent AddAgent(Vector3 position , CrowdAgentParams agentParams) { if (IsDisposed) { return(null); } IntPtr ptr = IntPtr.Zero; CrowdAgentCoreState initialState = new CrowdAgentCoreState(); int index = CrowdManagerEx.dtcAddAgent(root , ref position , ref agentParams , ref ptr , ref initialState); if (index == -1) { return(null); } mAgents[index] = new CrowdAgent(this, ptr, index); agentStates[index] = initialState; return(mAgents[index]); }
/// <summary> /// Updates the configuration for an agent. /// </summary> /// <param name="config">The new agent configuration.</param> public void SetConfig(CrowdAgentParams config) { if (!IsDisposed) { CrowdManagerEx.dtcUpdateAgentParameters(mManager.root , managerIndex , ref config); } }
/// <summary> /// Gets the agent configuration. /// </summary> /// <returns>The agent configuration.</returns> public CrowdAgentParams GetConfig() { CrowdAgentParams config = new CrowdAgentParams(); if (!IsDisposed) { CrowdAgentEx.dtcaGetAgentParams(root, ref config); } return(config); }
/// <summary> /// Copy constructor. /// </summary> /// <param name="config">The configuration to copy.</param> public CrowdAgentParams(CrowdAgentParams config) { this.radius = config.radius; this.height = config.height; this.maxAcceleration = config.maxAcceleration; this.maxSpeed = config.maxSpeed; this.collisionQueryRange = config.collisionQueryRange; this.pathOptimizationRange = config.pathOptimizationRange; this.separationWeight = config.separationWeight; this.updateFlags = config.updateFlags; this.avoidanceType = config.avoidanceType; this.userData = config.userData; }
/// <summary> /// Updates the configuration for an agent. /// </summary> /// <param name="config">The new agent configuration.</param> public void SetConfig(CrowdAgentParams config) { if (!IsDisposed) CrowdManagerEx.dtcUpdateAgentParameters(mManager.root , managerIndex , ref config); }
/// <summary> /// Gets the agent configuration. /// </summary> /// <returns>The agent configuration.</returns> public CrowdAgentParams GetConfig() { CrowdAgentParams config = new CrowdAgentParams(); if (!IsDisposed) CrowdAgentEx.dtcaGetAgentParams(root, ref config); return config; }
/// <summary> /// Adds an agent to the manager. /// </summary> /// <param name="position"> /// The current position of the agent within the navigation mesh. /// </param> /// <param name="agentParams">The agent configuration.</param> /// <returns> /// A reference to the agent object created by the manager, or null on error. /// </returns> public CrowdAgent AddAgent(Vector3 position , CrowdAgentParams agentParams) { if (IsDisposed) return null; IntPtr ptr = IntPtr.Zero; CrowdAgentCoreState initialState = new CrowdAgentCoreState(); int index = CrowdManagerEx.dtcAddAgent(root , ref position , ref agentParams , ref ptr , ref initialState); if (index == -1) return null; mAgents[index] = new CrowdAgent(this, ptr, index); agentStates[index] = initialState; return mAgents[index]; }
public NavAgentGroup CreateAgentGroup(int index, int maxPath, int maxStraightPath , out byte group) { group = mGroups[index * 2 + 0]; CrowdAgentParams cap = new CrowdAgentParams(); cap.avoidanceType = mGroups[index * 2 + 1]; cap.collisionQueryRange = mGroupData[index * GroupStide + QueryOffset]; cap.height = mGroupData[index * GroupStide + HeightOffset]; cap.maxAcceleration = mGroupData[index * GroupStide + AccelOffset]; cap.maxSpeed = mGroupData[index * GroupStide + JogOffset]; cap.pathOptimizationRange = mGroupData[index * GroupStide + OptiOffset]; cap.radius = mGroupData[index * GroupStide + RadiusOffset]; cap.separationWeight = mGroupData[index * GroupStide + SepOffset]; cap.updateFlags = mUpdateFlags[index]; NavAgentGroup result = new NavAgentGroup( cap, maxPath, maxStraightPath, mPoolData[index * 2 + 0], mPoolData[index * 2 + 1]); result.jogSpeed = mGroupData[index * GroupStide + JogOffset]; result.maxTurnSpeed = mGroupData[index * GroupStide + TurnOffset]; result.runSpeed = mGroupData[index * GroupStide + RunOffset]; result.walkSpeed = mGroupData[index * GroupStide + WalkOffset]; return result; }