private Vector3 calcAvgDir() { //Grab the current velocity values stored in the window Queue <Vector3> values = directionWindow.getValues(); //Get the sum of all velocities in the window Vector3 sum = new Vector3(0, 0, 0); foreach (Vector3 v in values) { sum += v; } //Get the normalised mean sum = (sum / values.Count).normalized; return(sum); }