Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        foreach (FlockAgent agent in agents)
        {
            List <Transform> context = GetNearbyObjects(agent);
            //agent.GetComponentInChildren<SpriteRenderer>().color = Color.Lerp(Color.white, Color.red, context.Count/6f); // demo

            Vector2 move = behavior.CalulateMove(agent, context, this);
            move *= driveFactor;
            if (move.sqrMagnitude > squareMaxSpeed)
            {
                move = move.normalized * maxSpeed;
            }
            agent.Move(move);
        }
    }