Skip to content

Instantly share code, notes, and snippets.

@TORISOUP
Created November 11, 2015 04:29
Show Gist options
  • Save TORISOUP/66a79ffb1f93eda96d86 to your computer and use it in GitHub Desktop.
Save TORISOUP/66a79ffb1f93eda96d86 to your computer and use it in GitHub Desktop.
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