Making all rigidbodies fall when countdown reaches zero.

I have platforms in my game that fall after a couple of seconds when the player walks on them.

I want to have it when a countdown reaches zero all the platforms in the scene fall.

I made this code and only a couple of them fall:

using UnityEngine;
using System.Collections;

public class FloorDrop : MonoBehaviour
{
public float dropDelay = 0.5f;
public int countValue = 1;
public int scoreValue = 10;

Rigidbody floorRigidBody;

void Start()
{
floorRigidBody = GetComponent();
}

void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == “Player”)
StartCoroutine(“Drop”, dropDelay);

if(WDGameManager.Instance.gameTimer <= 0)
{
AllDrop();
}
}

IEnumerator Drop(float delay)
{
yield return new WaitForSeconds(delay);

if (WDGameManager.Instance != null)
{
WDGameManager.Instance.blockCount += countValue;
WDGameManager.Instance.gameScore += scoreValue;
//GameManager.Instance.AdjustFloorCount(countValue);
//GameManager.Instance.AdjustScore(scoreValue);
}

if (floorRigidBody != null)
{
floorRigidBody.constraints = RigidbodyConstraints.None;
floorRigidBody.isKinematic = false;
}
//gameObject.AddComponent();
Destroy(gameObject, 2.0f);
}

void AllDrop()
{
if (floorRigidBody != null)
{
floorRigidBody.constraints = RigidbodyConstraints.None;
floorRigidBody.isKinematic = false;
}
//gameObject.AddComponent();
Destroy(gameObject, 2.0f);
}
}

What am i doing wrong?

Thanks.

Please read the stickied thread about code tags/how to post code in the forums.

I believe, at least one of your problems, is that you’re attempting to call DropAll() inside OnCollisionEnter, at a specific time.

You could set a time for them to drop at the start, if it’s a known time frame.
You could check the time in a coroutine/update , if the time changes.