Last active
October 11, 2018 00:49
-
-
Save aidiary/e867a474440d78d6fb6b to your computer and use it in GitHub Desktop.
円運動しながらマウスクリックでコインを出す
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
#pragma strict | |
// CoinSource.js | |
// 生成するCoinオブジェクト | |
// InspectorでCoinのPrefabをセットする | |
var coinObject : GameObject; | |
function Start () { | |
// 乱数シードを初期化 | |
Random.seed = System.Environment.TickCount; | |
} | |
function Update() { | |
// 原点を中心に円運動させる | |
transform.RotateAround(Vector3.zero, Vector3.up, 100 * Time.deltaTime); | |
// マウスクリックしたらコインを出す | |
if (Input.GetMouseButtonDown(0)) { | |
for (var i = 0; i < 5; i++) { | |
var clone : GameObject; | |
clone = Instantiate(coinObject, transform.position, transform.rotation); | |
clone.rigidbody.velocity.x = 10 * Random.Range(-1.0, 1.0); | |
clone.rigidbody.velocity.y = 50 * Random.Range(-1.0, 1.0); | |
clone.rigidbody.velocity.z = 10 * Random.Range(-1.0, 1.0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment