How to make one object drop when it be stepped on?

Now have a problem couldn’t solve.
However, my problem is I want to make an object drop after 1 second when the character step on it.
I’m not good at scripting, but I have done many things to make our project more complete. It’s really difficult to learn scripting by myself…
So is there anyone can help me? I’ve searched the forum for a long time but still couldn’t get any idea… :cry:

Put a trigger around this area. Then when the enter event is fired and the object that collided was the palyer, set a variable to say what the current Time.time is. Then in the staying (?) event of this trigger compare that variable to the actual Time.time and if > 1 second, activate the gravity of the thing you want it to fall. That would be the basic idea anyway.

Hi Rick, thanks for your reply. But I really didn’t figure out what I have to do that can follow the step you posted…I’d search through Unity Script Reference and still confuse about it. :sweat_smile:

What is Time.time? How can I use this function?

Maybe I can use onTriggerEnter or something like this, but I don’t know how to start with it.

Can anyone help with more details?

Time.time is the in-engine variable for the current time.

To try to simplify the explanation that was already given, here’s how you would do it: Over the platform you want to fall you would put a trigger. When it is triggered, you would want to set a variable to the current time, i.e. var playerEnteredAt = Time.time; then, in the OnTriggerStay block of code, you would have a comparison of (if Time.time >= (playerEnteredAt + 1)) you would either turn on gravity for the platform’s RigidBody or move it down manually with Translate.

Hopefully that helps :slight_smile:

Oh thanks ToxicHamster. I think I got it finally! I’ll try and post some result back here.

Now I’ve done by the code below

var playerEnteredAt =Time.time;

function OnTriggerStay () {
    dropTime= playerEnteredAt + 4;
	if (Time.time >= dropTime) {
		Destroy (GetComponent (MeshCollider));
		transform.Translate(-50*Time.deltaTime,-100*Time.deltaTime,0);
	}
}

(Destroy the MeshCollider is for not allowing player to still standing on the object.)
Here come’s a new problem. After the object dropped, player respawn at a place backward and has to retry. But how can I return the object to its position?
Need help again. :sweat_smile:

And now still a problem I did not find out.
My script let the object drop after about 4 seconds. But, works begin the level started. That means when player finally got the place of what the object was set, player will see an object already dropped and stop there!

Any idea to solve this? I’m gonna mad…