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 StopFlying(){ | |
// 運動の停止 | |
rb.velocity = Vector3.zero; | |
rb.angularVelocity = Vector3.zero; | |
// 初期位置に移動させる | |
gameObject.transform.position = initPosition; | |
// 距離測定中フラグをFalseにセット | |
isCheckingDistance = false; |
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 CheckDistance(){ | |
if (!isCheckingDistance){ | |
// 距離測定中でなければ何もしない | |
return; | |
} | |
if (rb.IsSleeping()){ | |
// スリープモードに入ったことを検知したら距離を出力 | |
stopPosition = gameObject.transform.position; | |
float distance = GetDistanceInXZ(initPosition, stopPosition); |
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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class SphereBooster : MonoBehaviour { | |
// 加える力の大きさ | |
[SerializeField] | |
float forceMagnitude = 10.0f; |
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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UI; | |
public class SphereBooster : MonoBehaviour { | |
// DistanceTextオブジェクトへの参照 | |
[SerializeField] | |
GameObject distanceTextObject; |
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 Start(){ | |
initPosition = gameObject.transform.position; | |
rb = gameObject.GetComponent<Rigidbody>(); | |
distanceText = distanceTextObject.GetComponent<Text>(); | |
// DistanceTextの初期値をセット | |
SetDistanceText(0f); | |
} |
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 CheckDistance(){ | |
if (!isCheckingDistance){ | |
// 距離測定中でなければ何もしない | |
return; | |
} | |
if (rb.IsSleeping()){ | |
// スリープモードに入ったことを検知したら距離を出力 | |
stopPosition = gameObject.transform.position; | |
float distance = GetDistanceInXZ(initPosition, stopPosition); |
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 SetDistanceText(float distance){ | |
// 受け取った距離の値を使って画面に表示するテキストをセット | |
distanceText.text = distancePrefix + distance.ToString("F2") + distanceSuffix; | |
} |
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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UI; | |
public class SphereBooster : MonoBehaviour { | |
// DistanceTextオブジェクトへの参照 | |
[SerializeField] | |
GameObject distanceTextObject; |
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
// DistanceTextオブジェクトへの参照 | |
[SerializeField] | |
GameObject distanceTextObject; | |
// HighScoreTextオブジェクトへの参照 | |
[SerializeField] | |
GameObject highScoreTextObject; | |
// 以下、string distanceSuffix = " m"; まで省略 |
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 Start(){ | |
initPosition = gameObject.transform.position; | |
rb = gameObject.GetComponent<Rigidbody>(); | |
distanceText = distanceTextObject.GetComponent<Text>(); | |
highScoreText = highScoreTextObject.GetComponent<Text>(); | |
// DistanceTextとHighScoreTextの初期値をセット | |
SetDistanceText(0f); | |
SetHighScoreText(0f); | |
} |