How to make a falling platform work with a timer?

So this what i’m working with at the moment.
public class FallingPlatform : MonoBehaviour
{
bool isFalling = false;
float downSpeed = 0;
public float interval;

void OnTriggerEnter(Collider collider)
{
if (collider.gameObject.tag == “Player”)

Debug.Log(“Hello”);
if (interval >= 0)
{
interval -= Time.deltaTime;
isFalling = true;
}
}

void Update()
{
if (isFalling)
{
downSpeed += Time.deltaTime/20;
Debug.Log(“Am I working?”);
transform.position = new Vector3(transform.position.x,
transform.position.y - downSpeed,
transform.position.z);
}
}
}

I want to have a timer to activate once the player has collided with the platform. Once the timer ends, it will drop the platform and the player wont be able to use it again.

With what I currently have, when the player enters the collides with the platform, only a small amount of the interval is taken out, it inst continuously going down

Hi,

Could you edit your post to use code tags so that it appears as a code block?

You need to think about your logic - what actually happens, try to explain to yourself or to a rubber duck. Then you probably see what’s wrong there. Go through it line by line.

One way to do this: you need to store a reference to the exact time when the player lands on the platform. Your OnTriggerEnter would be the place where you do it. You could have something like this in your class:

float triggerTime;

In your OnTriggerEnter you write the current time to that triggerTime:

triggerTime = Time.time;

Then, you check in your Update if enough time has passed:

if (Time.time - triggerTime > fallingThreshold)
{
   // Init falling
   isFalling = true;
}

Your fallingThreshold could be something you set in your Inspector, like 2 seconds or such.