3G Hiccups

In short, the 3GS has me spoiled. I’ve had to do a lot of optimization to get the 3G to even function remotely close to the 3GS, but I still have an annoying problem…

When my game starts, everything flows fine until I have to display a new GameObject that wasn’t already on the screen when the scene loaded. I pre-instantiate several of these GameObjects at startup, make them inactive, then make them active and position them in the scene when I need them. The first time displaying one of the objects, it usually makes the game stutter quite noticeably, which isn’t good for the type of game I’m creating. After this initial stutter, it will go smooth and then the stutter will reappear maybe 2-3 more times in the next 3 minutes of gameplay.

What causes this? Shouldn’t making it active and positioning it within view take few resources, given it’s been pre-instantiated?

My draw calls are always < 20, the heap stays the same and the garbage collector isn’t called once. The objects I am displaying are pre-instantiated and loaded into an array at startup, all textures are properly compressed, etc.

Thanks!

I have the same issue! I would be interested in a technique as well!

I’ve recently noticed a similar problem with mine - I’m preinstantiating everything and making it .active = false, and then moving them into place when needed and activating them

At the moment I’m only getting the stutters at the beginning of the level, once everything has been seen it runs nice and smoothly

I’m guessing I could maybe instantiate one instance of everything onscreen for a single update and then move them to stop this?

Yes–uploading a texture for the first time is generally what causes most of the problem, and textures are not uploaded until they are actually needed (i.e., visible), so simply instantiating an object and immediately disabling it will not do much.

–Eric

So if I instantiate it and display it on screen prior to disabling it, the stutter should be gone?

Is there a trick that can be used that effectively does the same thing without having to display the objects first? That will look a little awkward to show them at the beginning for (from the user’s perspective) no reason. Thx.

http://forum.unity3d.com/viewtopic.php?t=30485&start=1

–Eric

Awesome. Thanks Eric.

Ahhh wicked, thanks for that link Eric5h5 :slight_smile: