- Home /
void' is not an iterator interface type with collider "ERROR"
I was trying to remove a game object when you are interning a box collider, but my script is not working from some reason. I try to replace void whit IEnumerator but it give me a other error
"error CS1624: The body of DeathPit.OnTriggerEnter(UnityEngine.Collider)' cannot be an iterator block because
void' is not an iterator interface type"
So can someone help me ?
using UnityEngine;
using System.Collections;
public class DeathPit : MonoBehaviour {
public GameObject sasa;
void Start ()
{
sasa.SetActive (false);
}
void Update ()
{
}
IEnumerator OnTriggerEnter(Collider broseidon)
{
if(broseidon.tag == "Player")
{
broseidon.transform.position = broseidon.GetComponent<Player>().checkPos;
sasa.SetActive (true);
yield return WaitForSeconds(0.5);
sasa.SetActive (false);
}
}
}
Here is the script
Answer by DoTA_KAMIKADzE · Jun 19, 2015 at 09:57 PM
That error should not appear for you because you have already changed void to IEnumerator in code provided in your question, thought you should have another error due to line #29, which should be:
yield return new WaitForSeconds(0.5f);
Your answer
Follow this Question
Related Questions
OnCollisionEnter wheel collider error! 4 Answers
RaycastHit.normal - what does it really return? 4 Answers
First person character walking through terrain? 2 Answers
OnCollisionEnter2D not working? 2 Answers
Colldier problem, any help? 4 Answers