Creating Objects at Run Time

Hello everyone, i saw in temple run 2, that environment gets created as the player moves forward? Whats that? Are prefabs instantiated at run time? Will those not cause jerks in game? Or are objects created at start of scene and are just activated and deactivated? I have a big scene with high number of polys, i was looking to adopt temple run approach, but i am a bit confused. Kindly help me. Thanks

First instantiate will cause noticeable hiccups if the prefab has lots of texture or vertex data.

No need to activate/deactivate since you can just move the outrun objects behind the camera and move them back in when needed.

Currently what i am doing is creating all objects at the start of scene, neither creating prefabs nor activating deactivating, but the app crashes due to memory on ipod 4G. Working correctly on newer devices. Thats why i was looking for a solution for proper memory management.

Is there a downside to activating/deactivating?

It depends about the situation. If the track parts are just textured cubes, there shouldn’t be any issues. But there might be issues with particles, sounds, triggers etc. since you might need to stop their logic before/after moving.

You should use profiler to see what is eating the memory, I would guess that textures are the biggest eater of the memory.