protected override Vector2?CalculateForceComponentsInternal() { activation = 0.0f; var visibleAgentsCount = m_sensor.touchingObjects.Count; var meanPosition = Vector2.zero; foreach (var collider in m_sensor.touchingObjects) { var agent = collider.GetComponent <ParentAgent>()?.agent; if (agent == null) { continue; } meanPosition += agent.position; } if (visibleAgentsCount <= 0) { return(null); } meanPosition /= visibleAgentsCount; activation = 1.0f; return(SteeringBehaviourUtils.Flee(meanPosition, this)); }
protected override Vector2?CalculateForceComponentsInternal() { if (m_threat == null) { return(null); } activation = 1.0f; return(SteeringBehaviourUtils.Flee(m_threat.position, this)); }
protected override Vector2?CalculateForceComponentsInternal() { activation = 0.0f; if (m_sensor == null) { return(null); } var visibleObstaclesCount = m_sensor.touchingObjects.Count; var meanPos = Vector2.zero; foreach (var obstacle in m_sensor.touchingObjects) { meanPos += (Vector2)obstacle.transform.position; } activation = visibleObstaclesCount > 0 ? 1.0f : 0.0f; var force = visibleObstaclesCount > 0 ? SteeringBehaviourUtils.Flee(meanPos, this) : Vector2.zero; return(force); }
protected override Vector2?CalculateForceComponentsInternal() { activation = 1.0f; return(SteeringBehaviourUtils.Flee(m_targetPosition, this)); }