i need help scripting i dont understand any part of scripting
I can post you this script, it makes objects remove themselves after a set period of time
var lifeTime : float = 10; //how long the object should live in seconds
private var timeStamp; //keeps track of the time
function Awake()
{
timeStamp = Time.time; //at creation of object, note the time
}
function Update ()
{
//check if the time has ticked past the time since we created object + the lifetime we want
if( ( timeStamp+lifeTime ) < Time.time)
{
Destroy( gameObject );
}
}
if you want to fade something over time (that is make the object more transparent), you can use the timecheck to modulate the alpha value of an object. That could be done in the if-statement in Update (if you want nothing to happen until after a set amount of time)
Hope it helped!
I found another (possibly faster) way. It's as easy as:
Destroy(gameObject, numberOfSeconds);
as soon as you create the object, you set it to be destroyed in a certain number of seconds. Cheers!