private float ChangeAngularSpeed(float angularSpeed, float radius, float time) { float parachuteAngularSpeed = JumpPhysics.LinearToAngularVelocity(parachuteConfiguration.XVelocity, radius); if (angularSpeed > parachuteAngularSpeed) { angularSpeed = Mathf.Clamp(angularSpeed - JumpPhysics.LinearToAngularVelocity(parachuteConfiguration.XAccel * time, radius), parachuteAngularSpeed, float.PositiveInfinity); } return(angularSpeed); }
public Vector3 FindNextPosition(float yVelocity, float angularSpeed, ref float angel, float radius, float gravity, float distance, ref float currentTimeSlice, Vector3 lastPos, Vector3 startPos) { Vector3 position; //Time where distance still to small float minTime = currentTimeSlice; //time where distance still to big float maxTime = 0; float currentDistance = 0; int left = 0, right = 0; int currentIterations = maxIterationtonToFindAccuratePos; float currentAngel; do { if (currentDistance > distance) { left++; maxTime = currentTimeSlice; currentTimeSlice = (maxTime + minTime) / 2; } else if (currentDistance < distance) { right++; minTime = currentTimeSlice; if (maxTime == 0) { currentTimeSlice += timeStep; } else { currentTimeSlice = (maxTime + minTime) / 2; } } currentAngel = angel; position = JumpPhysics.CalculatePositionAtTime(yVelocity, angularSpeed, ref currentAngel, radius, currentTimeSlice, gravity, startPos); currentDistance = Vector3.Distance(lastPos, position); } while (--currentIterations > 0 && (currentDistance < distance || currentDistance - distance > accuracyDelta)); angel = currentAngel; if (currentIterations <= 0) { Debug.LogWarning("can't get accuracy left: " + left + " right: " + right); } return(position); }