I am making a grenade and want a timer, so it doesn't explode as soon as it hits the ground. What script is used for this?
Take a look at WaitForSeconds. Then, assuming you want the timer to start from when the grenade is thrown, do something like:
- Instantiate the grenade
- Wait for as many seconds as you want (using the above method)
- Play an explosion sound, spawn a particle effect, destroy the gameObject, etc
In future, you should try scripting it yourself and then post if you have problems (that you can't find a solution for by searching). Otherwise you'll usually have your question tagged as 'write-my-code', and generally they're ignored.
Instantiate the grenade...
Destroy(gameObject, 5);
http://unity3d.com/support/documentation/ScriptReference/Object.Destroy.html
Particle Effect the grenade...
Well i will be happy to right your code. But this may not work. But go ahead and try it.
function Update ()
{
yeild WaitForSeconds(5);
Destroy (gameObject)
}
If this does not work for you search up yeild wait for seconds but this should work. You have to code your own particle emiter though. So you got to do a bit coding yourself too you know.