void ReshapeTract(float deltaTime) { float amount = deltaTime * movementSpeed; int newLastObstruction = -1; for (int i = 0; i < n; i++) { float diam = diameter[i]; float targetDiam = targetDiameter[i]; if (diam <= 0) { newLastObstruction = i; } float slowReturn; if (i < noseStart) { slowReturn = 0.6f; } else if (i >= tipStart) { slowReturn = 1.0f; } else { slowReturn = 0.6f + 0.4f * (i - noseStart) / (tipStart - noseStart); } diameter[i] = MathfExtensions.MoveTowards(diam, targetDiam, slowReturn * amount, 2.0f * amount); } if (lastObstruction > -1.0 && Mathf.Abs(newLastObstruction - -1.0f) < EPSILON && noseA[0] < 0.05f) { AddTransient(lastObstruction); } lastObstruction = newLastObstruction; amount = deltaTime * movementSpeed; noseDiameter[0] = MathfExtensions.MoveTowards(noseDiameter[0], velumTarget, amount * 0.25f, amount * 0.1f); noseA[0] = noseDiameter[0] * noseDiameter[0]; }