When a tree falls in a forest ...

Hi there

I just wanted to gain some insight in game design practices.

If a game has a number of NPCs that are not in camera view, say, for the first 15 minutes of the gameplay, then it would seem logical to simply instantiate them when the player hits a point in the map and the they are about to come into camera view? Sorta Occulsion Culling? Or does Unity have some sort built-in performance solution for this.

The same with a flickering light - it would be best to instantiate the light just as it comes into view? And destroy it when it is no longer required?

Any insight would be great

R

Would you have to destroy it or just UnRender it. :?:

And while were at it, when i unrender a single object it give 2 less drawcall instead of one, why is that? :smile:

But with ‘Unrender’ is the prefabs scripts maybe still ‘activate’ - it still pulls on the performance?

I would love to get a perspective on how devs create their levels/optimize them.

R

Multiple draw calls may be made for a single object for a few reasons. I think some things like additional lighting, textures, among others can increase the draw call count.

I think you can set a script’s “enabled” property to false and that will halt scripts. (it might only affect the Updated method, I’m not sure)

I believe you can also disable the GameObject’s Renderer component in the same way.

I don’t think Unity has a built-in performance with regards to running your scripts. You can put scripts on OnBecameVisible and OnBecameInvisible for example to enable/disable your objects. There are likely underyling performance optimizations for handling objects not in your view. Maybe just try it out and see how your game’s performance is.

Unity does simple frustum culling by default (near clip - far clip), thus, an object is not “loaded and rendered” if it’s out of camera view.

An object can have a lot of draw calls depending on materials, uvw maps, number of shadow casting lights, etc.

I have no idea about the scripts, I’m just a lowly artist here.

The two draw calls are for a sphere with rigidbody, no mat. Same if has a mat. :smile:

When walking around my lvl’s the trees snap into place and rotate a little when i get close to them. How can i adjust this? :idea:

If a sphere had absolutely no material, you wouldn’t see it. A sphere with the Default Material is actaully Diffuse, which has two draw calls due to its material type (if you want only one draw call, change it to something like a VertexLit material and see if it gives the results you want).

The trees rotating and snapping into place is due to the tree billboards in the distance turning into actual mesh trees when you get closer to them. There are ways to adjust this so that the change happens more gradually and/or further back from the camera.