Created
November 11, 2015 04:29
-
-
Save TORISOUP/66a79ffb1f93eda96d86 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
void Update() | |
{ | |
intervalTime += Time.deltaTime; | |
// マウス入力で左クリックをした瞬間 | |
if (Input.GetMouseButtonDown(0)) | |
{ | |
if (intervalTime >= 3.0f) | |
{ | |
StartCoroutine(CreatePrefabCoroutine()); | |
intervalTime = 0.0f; | |
} | |
} | |
} | |
IEnumerator CreatePrefabCoroutine() | |
{ | |
var clickPosition = Input.mousePosition; | |
clickPosition.z = 10f; | |
var obj = (GameObject)Instantiate(Prefab, Camera.main.ScreenToWorldPoint(clickPosition), Prefab.transform.rotation); | |
obj.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; | |
//2秒待つ | |
yield return new WaitForSeconds(2); | |
obj.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.None; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment