|
Hi. I need a very simple script that will destroy a game object with a set tag after a certain amount on time set in a variable. Thank you!
(comments are locked)
|
http://unity3d.com/support/documentation/ScriptReference/Object.Destroy.html he did say simple, though!
Jan 03 '11 at 01:28 AM
Jesus_Freak
i fixed my code so it will only destroy one time.
Jan 03 '11 at 01:40 AM
Jesus_Freak
I think this would work, however I do not need to do what I wanted before, so I won't test it. Sorry. However, thank you for your guy's ideas and input! Thank you also to the one below by Unity3_User. I will give you best answer Jessy because I think that would work easier, but you both deserve points for it!
Jan 04 '11 at 01:45 AM
Keavon
(comments are locked)
|
i hope this helps, i'm using it to make a "stop game" effect. and the time and all works. this is a unityscript.
Jan 03 '11 at 12:32 AM
Jesus_Freak
There are 60 seconds in an Earth minute, not 100. Multiplying something by 1 serves no purpose. Your code will cause errors after the first Destroy(), because it will attempt to Destroy the same object every frame, after timeToWait is up, and that object will no longer exist after the first Destroy().
Jan 03 '11 at 12:50 AM
Jessy
it's not adding 1 seconds every seconds, it's adding 1 VALUE every frame. at the rate the frames are called, 10.00 if it was above, would be 1 second. but i agree to the 1 times anything by itself rule. 7th grade math. and the destroy function, but this script makes it somehow, that 100 = 1 minute. try it, turn the timer into a String, GUI.Box(rectInfo, timer.ToString("f0")); and see what happens. compare that to the System.DateTime.Now. then you will see how 100 = 1 minute.
Jan 03 '11 at 01:27 AM
Jesus_Freak
Time.deltaTime is what makes that possible. and that already does the 60seconds = 1minute thing, it's adding .03 or there around, every frame, and that makes it so that the 10.00 is 1 second, 100.00 is 1 minute, and 1000.00 is ten minutes.
Jan 03 '11 at 01:38 AM
Jesus_Freak
You don't understand Time.deltaTime. Look it up in the docs to see what it means. If you still believe what you have said, after that, please post code above that supports your findings.
Jan 03 '11 at 02:02 AM
Jessy
(comments are locked)
|

If you just need any Game Object destroyed, please change your title and edit your tags to get rid of the irrelevant references.