void FixedUpdate() { // Handle Avoidance Stuff Collider[] avoidanceColliderArray = Physics.OverlapSphere(transform.position, avoidanceFilterRange, avoidanceMask); List <GameObject> avoidanceList = new List <GameObject>(); foreach (Collider collider in avoidanceColliderArray) { if (collider.gameObject != this.gameObject) { avoidanceList.Add(collider.gameObject); } } // Handle Goal Stuff Collider[] goalColliderArray = Physics.OverlapSphere(transform.position, avoidanceFilterRange, goalMask); List <GameObject> goalList = new List <GameObject>(); if (defaultGoal != null && goalColliderArray.Length == 0) { goalList.Add(defaultGoal); } else { foreach (Collider collider in goalColliderArray) { GameObject collidedObject = collider.gameObject; if (collidedObject != this.gameObject && collidedObject != defaultGoal) { if (Player.Instance.gameObject == collidedObject) { if (Player.Instance.Alive) { goalList.Add(collider.gameObject); } } else { goalList.Add(collider.gameObject); } } } } // Set Up BoidScript boidScript.GoalList = goalList; boidScript.AvoidanceList = avoidanceList; Vector3 boidVelocity = boidScript.UpdateVelocity(); // Add Force to Rigidbody if (boidVelocity.sqrMagnitude > 0 && rigidbody != null) { boidVelocity.y = 0; Vector3 newForce = Vector3.Normalize(boidVelocity) * acceleration * BoidSpawnManager.Instance.BoidSpeedMultiplier / rigidbody.mass; transform.rigidbody.AddForce(newForce, ForceMode.Force); } }