예제 #1
0
    public void ComputeAgentBehavior(int NNCount, int avoidCount, Vector3 alignmentMove, Vector3 avoidanceMove, Vector3 cohesionMove)
    {
        Vector3 acceleration = Vector3.zero;

        acceleration += behaviors.ComputeAlignmentBehavior(NNCount, alignmentMove, agentSettings.alignmentWeight);
        if (NNCount != 0)
        {
            acceleration += behaviors.ComputeCohesionBehavior(cohesionMove, position, forwardDirection, cohesionCurrVel, agentSettings.cohesionWeight, agentSettings.cohesionSmoothTime);
        }
        if (avoidCount != 0)
        {
            acceleration += behaviors.ComputeSeparationBehavior(avoidanceMove, agentSettings.avoidanceWeight);
        }

        acceleration += behaviors.ComputeEnvironmentColisionsBehavior(position, forwardDirection, agentSettings.collisionWeight, agentSettings.collisionAvoidDistance, agentSettings.sphereCastRadius, agentSettings.obstaclesLayer);

        velocity += acceleration * Time.deltaTime;
    }