x


Regaining system resources?

In the game I'm making there's 5 instanciaters which will birth 2 objects a piece over the life of the level. The objects themselves are baskets with 3 balloons attached and have about 100 faces or less, as the baskets move across the screen you can fire arrows at them which if don't hit the balloons will be destroyed after 2 seconds and the baskets and leftover balloons are destroyed once they hit a collider outside of the view. The game runs smooth until the last 2 objects are born and then starts to run a little slower. If i reload the game by refreshing the browser it runs perfect again until the last 2 objects. The only Update Functions in the game are attached to the bow and arrow for aiming reasons and on the baskets to move them across the screen but those are destroyed once they cross the screen. I have the fixed timestep set at .01 because .02 lets the arrows fly trough the balloons without destroying them, but even at .02 the game still slows at the same time. Any ideas on why it would do this or how to fix it? thanks

more ▼

asked Feb 05 '10 at 04:26 PM

ThumbStorm gravatar image

ThumbStorm
418 27 33 42

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Try not to destroy but to deactivate the game objects.
The next Application.LoadLevel() does the job :-)

There are a couple of answers regarding performance issues of Object.Destroy() and garbage collector runs. (search for 'destroy')

more ▼

answered Feb 05 '10 at 04:52 PM

efge gravatar image

efge
5.1k 5 14 38

Sweet, Your absolutely right. Do you think it would be better to instantiate all 10 objects in the awake function instead of individually during run time?

Feb 05 '10 at 08:46 PM ThumbStorm

Instancing GameObjects should not be an issue. But you could give it a try.

Feb 08 '10 at 12:56 PM efge
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x492
x216

asked: Feb 05 '10 at 04:26 PM

Seen: 850 times

Last Updated: Feb 05 '10 at 04:26 PM