Skip to content

Instantly share code, notes, and snippets.

@todorok1
Created May 1, 2018 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todorok1/87f14143dc510bb61c14cf7956619d10 to your computer and use it in GitHub Desktop.
Save todorok1/87f14143dc510bb61c14cf7956619d10 to your computer and use it in GitHub Desktop.
Unityチュートリアル・ゴルフゲームの進行を制御するスクリプト
void CheckDistance(){
if (!isCheckingDistance){
// 距離測定中でなければ何もしない
return;
}
// 現在位置までの距離を計算する
Vector3 currentPosition = gameObject.transform.position;
float distance = GetDistanceInXZ(prePosition, currentPosition);
// UIテキストに表示
SetDistanceText(distance);
if (rb.IsSleeping()){
// ハイスコアのチェック
stopPosition = currentPosition;
float currentDistance = GetDistanceInXZ(prePosition, stopPosition);
if (currentDistance > highScoreDistance){
highScoreDistance = currentDistance;
}
SetHighScoreText(highScoreDistance);
// 距離測定中フラグをオフに
isCheckingDistance = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment