public unsafe DtAgentParams GetAgentParams(int idx) { DtAgentParams result = default;; Navigation.Crowd.GetAgentParams(DtCrowd, idx, new IntPtr(&result)); return(result); }
public bool Equals(DtAgentParams other) { return(Radius.Equals(other.Radius) && Height.Equals(other.Height) && MaxAcceleration.Equals(other.MaxAcceleration) && MaxSpeed.Equals(other.MaxSpeed) && CollisionQueryRange.Equals(other.CollisionQueryRange) && PathOptimizationRange.Equals(other.PathOptimizationRange) && SeparationWeight.Equals(other.SeparationWeight) && AnticipateTurns.Equals(other.AnticipateTurns) && OptimizeVis.Equals(other.OptimizeVis) && OptimizeTopo.Equals(other.OptimizeTopo) && ObstacleAvoidance.Equals(other.ObstacleAvoidance) && CrowdSeparation.Equals(other.CrowdSeparation) && ObstacleAvoidanceType.Equals(other.ObstacleAvoidanceType) && SeparationWeight.Equals(other.SeparationWeight)); }
public int AddAgentAtRandomPosition(DtAgentParams agentParams, AiNavQuery query) { float3 onMesh = default; if (Navigation.Query.GetRandomPosition(DtNavMesh, ref onMesh) == 1) { return(AddAgent(onMesh, agentParams)); } return(-1); }
private void Start() { var navSystem = EcsWorld.Active.GetExistingSystem <AiNavSystem>(); Controller = navSystem.GetSurfaceController(SurfaceId); if (Controller == null) { Destroy(gameObject); return; } var query = new AiNavQuery(Controller.NavMesh, 2048); float3 extent = new float3(5f, 5f, 5f); float3 position = transform.position; if (!query.GetRandomPosition(ref position)) { query.Dispose(); Debug.Log("Spawn position not found"); Destroy(gameObject); return; } query.Dispose(); DtAgentParams agentParams = DtAgentParams.Default; agentParams.MaxSpeed = 6f; if (Controller.CrowdController.TryAddAgent(position, agentParams, out NavAgent agent)) { var world = EcsWorld.Active; Entity entity = world.EntityManager.CreateEntity(); world.EntityManager.AddComponentData(entity, agent); world.EntityManager.AddComponentData(entity, new AgentPathData()); world.EntityManager.AddBuffer <AgentPathBuffer>(entity); transform.position = position; CrowdIndex = agent.CrowdIndex; } else { Debug.Log("Failed adding agent"); Destroy(gameObject); return; } }
public bool TryAddAgent(float3 position, DtAgentParams agentParams, out NavAgent agent) { agent = new NavAgent { Active = true, DtAgentParams = agentParams, Destination = position }; if (AiCrowd.TryAddAgent(position, agentParams, out int crowdIndex)) { agent.CrowdIndex = crowdIndex; return(true); } else { return(false); } }
public void SetAgentParams(int idx, DtAgentParams agentParams) { Navigation.Crowd.SetAgentParams(DtCrowd, idx, ref agentParams); }
public int AddAgent(float3 position, DtAgentParams agentParams) { return(Navigation.Crowd.AddAgent(DtCrowd, ref position, ref agentParams)); }
public bool TryAddAgent(float3 position, DtAgentParams agentParams, out int agentIndex) { agentIndex = Navigation.Crowd.AddAgent(DtCrowd, ref position, ref agentParams); return(agentIndex >= 0); }
public static extern void SetAgentParams(IntPtr crowd, int idx, ref DtAgentParams agentParams);
public static extern int AddAgent(IntPtr crowd, ref float3 position, ref DtAgentParams agentParams);