Last active
April 21, 2018 08:35
-
-
Save todorok1/b1d76cf7b3fc320ea4dc2fac0decc1ca to your computer and use it in GitHub Desktop.
Unityチュートリアル・打ち出す力のメーターを上下させるスクリプト。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void MovePowerMeter(){ | |
// 飛行中フラグがfalseの時にメーターを上下させる | |
if (isFlying){ | |
return; | |
} | |
// 境界値の定義 | |
float boundaryValue = 0f; | |
// forceMagnitudeにmeterSpeedの値を加えていってメーターを上下させる | |
if (isMeterIncreasing){ | |
powerMeterSlider.value += meterSpeed; | |
boundaryValue = powerMeterSlider.maxValue; | |
} else { | |
powerMeterSlider.value -= meterSpeed; | |
boundaryValue = powerMeterSlider.minValue; | |
} | |
// 境界値になったら少し止めた後にメーターを逆向きに動かす | |
if (Mathf.Approximately(powerMeterSlider.value, boundaryValue)){ | |
WaitAtBoundaryValue(); | |
} | |
// スライダーの現在値をforceMagnitudeに格納 | |
forceMagnitude = powerMeterSlider.value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment