Problem detection collider with coroutine

Hello,

I’m made ​​a Bomberman but I have a little problem with my script collision detection. My script detects the boxes without coroutine, so that when I put my coroutine it no longer detects the boxes … Would you please solution.

using UnityEngine;

using System.Collections;

 

public class DestroyCube : MonoBehaviour {

    

    public BoxCollider box1;

    public BoxCollider box2;

 

    void OnCollisionEnter(Collision collision) 

    {

        if(collision.gameObject.name == "Cube")

        {

            Debug.Log ("Destroy Cube");

            Destroy(collision.gameObject, 4);

        }

        else if(collision.gameObject.name == "Capsule")

        {

            Debug.Log ("Destroy Capsule");

            Destroy(collision.gameObject, 4);

        }

    }

 

    IEnumerator Start () {

        yield return new WaitForSeconds (4);

        box1 = gameObject.AddComponent<BoxCollider>();

        box2 = gameObject.AddComponent<BoxCollider>();

        box1.size = new Vector3 (0.1f,3,6);

        box2.size = new Vector3 (6,3,0.1f);

    }

}

thanks you in advance.

Don’t make Start a coroutine, instead call all the things you want to set up in another method which you can call with a 4 second delay via Invoke.