- Home /
Question by
Chris12345 · Aug 04, 2012 at 10:00 PM ·
getcomponentoncollisionenterwaitforseconds
How could i convert this from java to #c
How could i convert this from java to #c
#pragma strict
function OnCollisionEnter(collision : Collision) {
if(collision.gameObject.tag =="Whatever")
yield WaitForSeconds(10);
GetComponent(MeshRenderer).enabled = false;
}
Comment
Will you use this script with a C# script? If yes, you don't need to convert, search for Unity Scripts Communication.
no, I just need this covered to c# thanks for your help.
Best Answer
Answer by darthbator · Aug 04, 2012 at 10:52 PM
Would look something like
void OnCollisionEnter(Collision collision) {
if(collision.gameObject.tag =="Whatever")
StartCoroutine(waitMethod());
}
IEnumerator waitMethod () {
yield return new WaitForSeconds(10);
GetComponent(MeshRenderer).enabled = false;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613075207im_/https://answers.unity.com/themes/thub/images/avi.jpg)