KAS.KASModuleWinch.BringMotorToSpeed C# (CSharp) Méthode

BringMotorToSpeed() public méthode

Accelerates or decelerates the motor to match the target speed.
Acceleration is controlled via motorAcceleration which specifies speed change per second.
public BringMotorToSpeed ( float targetSpeed ) : void
targetSpeed float
Résultat void
        void BringMotorToSpeed(float targetSpeed)
        {
            if (!Mathf.Approximately(motorSpeed, targetSpeed)) {
              var scaledMotorAcceleration = motorAcceleration * TimeWarp.deltaTime;
              if (motorSpeed < targetSpeed) {
            motorSpeed += scaledMotorAcceleration;
            if (motorSpeed > targetSpeed) {
              motorSpeed = targetSpeed;
            }
              } else {
            motorSpeed -= scaledMotorAcceleration;
            if (motorSpeed < targetSpeed) {
              motorSpeed = targetSpeed;
            }
              }
            }
        }