private bool AccumulateForce(ref Vector3 currentForce, Vector3 forceToAdd) { //How much steering force has this entity used so far float magnitudeSoFar = currentForce.magnitude; //How much steering force remains to be used float magnitudeRemaining = m_movingEntity.getMaxForce() - magnitudeSoFar; //return false if there's no more force left to use if (magnitudeRemaining <= 0.0f) { return(false); } float magnitudeToAdd = forceToAdd.magnitude; if (magnitudeToAdd < magnitudeRemaining) { currentForce += forceToAdd; } else { currentForce += Vector3.Normalize(forceToAdd) * magnitudeRemaining; } return(true); }