- Home /
Question by
Maestro_Kitty · Aug 14, 2017 at 05:53 PM ·
3dtimerplatformerdisappear
Objects won't disappear after a set time after collision
I'm trying to create a platform that will disappear after a set number of seconds, once the Player steps on it. The code I've been using does nothing:
public float Seconds = 2;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.name == "Player")
{
Poof();
}
}
IEnumerator Poof()
{
yield return new WaitForSeconds(Seconds);
gameObject.SetActive(false);
}
I really don't know what I'm doing wrong. Would somebody kindly help me? Thank you.
Comment
Best Answer
Answer by bart1259 · Aug 14, 2017 at 05:59 PM
StartCoroutine(Poof);
instead of
Poof()
https://docs.unity3d.com/ScriptReference/MonoBehaviour.StartCoroutine.html
Thank you, but it still isn't working. When I use that, it won't let me use Poof as an IEnumerator.