protected void DriveMechanism()
 {
     if (Input.GetKey(positive))
     {
         mechanism.Drive(velocity, type);
     }
     else if (Input.GetKey(negative))
     {
         mechanism.Drive(-velocity, type);
     }
 }
示例#2
0
        /// <summary>
        /// Update motor.
        /// </summary>
        protected virtual void Update()
        {
            if (Mathf.Abs(currentRPM - targetRPM) <= threshold)
            {
                currentRPM = targetRPM;
            }
            else
            {
                currentRPM = Mathf.Lerp(currentRPM, targetRPM, damper * Time.deltaTime);
            }

            if (currentRPM == 0)
            {
                enabled = false;
            }
            else
            {
                if (axle.IsStuck)
                {
                    LogUtility.LogWarning("The axle is stuck, drive is cancelled.");
                    return;
                }

                axle.Drive(currentRPM * 6, DriveMode.Angular);
            }
        }
示例#3
0
        /// <summary>
        /// Update motor.
        /// </summary>
        protected virtual void Update()
        {
            if (Mathf.Abs(currentRPM - targetRPM) <= threshold)
            {
                currentRPM = targetRPM;
            }
            else
            {
                currentRPM = Mathf.Lerp(currentRPM, targetRPM, damper * Time.deltaTime);
            }

            if (currentRPM == 0)
            {
                enabled = false;
            }
            else
            {
                axle.Drive(currentRPM * 6, DriveType.Angular);
            }
        }
示例#4
0
 /// <summary>
 /// Drive mechanism by velocity.
 /// </summary>
 /// <param name="velocity">Velocity of drive.</param>
 /// <param name="mode">Mode of drive.</param>
 /// <returns>Drive is unrestricted?</returns>
 public bool Drive(float velocity, DriveMode mode)
 {
     return(mechanism.Drive(velocity * coefficient, mode));
 }