Last active
April 18, 2018 12:01
-
-
Save todorok1/23008f71603da6111310a61b97bb5536 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 SetGuidePositions(){ | |
// 『GuideParent』の位置を『Sphere』オブジェクトの位置へ移動 | |
gameObject.transform.position = player.transform.position; | |
// 『GuideParent』の位置を開始位置に設定 | |
Vector3 startPos = gameObject.transform.position; | |
// リストの検証 | |
if (guideList == null || guideList.Count == 0){ | |
return; | |
} | |
// 物理学的なパラメータを取得 | |
// 『Sphere』オブジェクトに加わる力 | |
Vector3 force = sphereBooster.GetBoostForce(); | |
// 『Sphere』オブジェクトの質量 | |
float mass = sphereRb.mass; | |
// Unityの世界に働く重力 | |
Vector3 gravity = Physics.gravity; | |
// 『Sphere』オブジェクトが斜方投射される時の初速度 | |
Vector3 speed = force / mass; | |
// プロット数に応じて、各プロットの時刻をリストに格納 | |
List<float> timeProtsList = GetTimeProtsList(speed, gravity, prots); | |
// リストの検証 | |
if (timeProtsList == null || timeProtsList.Count == 0){ | |
return; | |
} | |
// 時刻リストを元に、プロットするガイドの位置を設定 | |
for (int i = 0; i < prots; i++){ | |
// リストから時刻の値を取り出す | |
float time = timeProtsList[i]; | |
// リストで対応するインデックスのガイドオブジェクトについて位置を設定 | |
guideList[i].transform.position = GetExpectedPosition(startPos, speed, gravity, time); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment