Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        //Gizmos.DrawWireSphere(transform.position, searchRadius);
        Collider2D[] nearUnits = Physics2D.OverlapCircleAll(transform.position, searchRadius);
        Vector3      meanPos   = new Vector3(player.transform.position.x, player.transform.position.y, -10);

        foreach (Collider2D unit in nearUnits)
        {
            if (unit.transform.CompareTag("Enemy"))
            {
                calcUnits += 1;
                meanPos   += new Vector3(unit.transform.position.x, unit.transform.position.y, -10) * enemyWeight;
            }
        }
        meanPos            = meanPos / (calcUnits * enemyWeight + 1);
        calcUnits          = 0;
        transform.position = CamPosSlerp((start, end) => Mathf.Lerp(start, end, followSpeed))(transform.position, meanPos);
    }
 // Update is called once per frame
 void Update()
 {
     transform.position = CamPosSlerp((start, end) => Mathf.Lerp(start, end, followSpeed))(transform.position, focalPoint.transform.position);
 }