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.