Respawning gameobject

private Rigidbody2D RB2D;

public float fallDelay;             // The time before platform falls
public float RespawnDelay;          // The time before platform respawns
public Transform Spawnpoint;        // Objects spawnpoint

void Start()
    RB2D = GetComponent<Rigidbody2D>();

void OnCollisionEnter2D(Collision2D col)
    if ( == ("Player"))

IEnumerator Fall()
    yield return new WaitForSeconds(fallDelay);            // Wait platform to fall
    RB2D.isKinematic = false;                              // Not kinematic so it falls
    GetComponent<Collider2D>().isTrigger = true;           // Is trigger now so won't collide
    Destroy(RB2D.gameObject, 12);                          // Destroy object after set time
    yield return new WaitForSeconds(RespawnDelay);         // Wait respawn delay
    RB2D.isKinematic = true;                               // Kinematic again so it won't fall
    GetComponent<Collider2D>().isTrigger = false;          // Is trigger again so collions apply
    Instantiate(RB2D, Spawnpoint.position, Spawnpoint.rotation);// Instantiate to the Spawnpoint
    yield return 0;

What it does:
There is platform on scene that when player is colliding with it, it soon falls and after set time it respawns to the spawnpoint and then is destroyed after player again collides with it.

It currently works quite nice BUT when it creates new instances, it makes clones of itself so finaly there is like “gameobject(clonecloneclone…)”. Just looks stupid and there surely is better way.

Also, now I must wait before destroying the gameobject or else I can’t spawn it anymore because it doesn’t exists.

So, how could I make the code better?
I read about disabling it only and not destroying it but couldn’t get it to work…

While I copied parts of it from web, I made it also suit better my needs, and since I’m still quite new to coding I could had surely made it better. Any thoughts of it overall all welcome.

Why destroy the game object when you can just move it to the spawn point?

Use this instead of the Destroy line.

RB2D.transform.position = Spawnpoint.transform.position;

This is bad for performance especially on mobile devices.
Anyway there’s a much better way that doesn’t have the heavy "instantiate " : Stack.

You can declare a Stack and put your objects to it and recycle your objects instead of instantiating them every time.

The “clone” problem is really easy. After you’ve declared your Stack , you can declare a name to all the clones.

If your Stack name is RBs , then you can write:

RBs.peek().name = "RB";