- Home /
Objects are slowing game
Hello! I have a little problem. On my Planet (this is a big sphere, 50 units scale) I created a Trees Generator. It's generating 600 trees around my Planet. When I'm looking forward FPS is OK, but when I'm looking down I have big lags and 20 FPS (normal is 60). I know why - because when I look down all the trees are "visible" and this slow game. So - You have any idea to fix that? I want to create big planets with more trees, but I can't solve this problem.
Sorry for my english and Thanks in advance! :)
Hi, I'd check how to define occluders and place one in the center of the planet (I don't know more about this but there are new features in Unity 5 about occluders) I guess you could also try different values for tree LOD.
Hey, just got an idea: if your planet is a sphere and you have a list of the tree's gameobjects, you could go over the list of trees and check their transform.up vector against the vector between the camera origin and the tree origin using a dot product (vector3.dot). Then, the dot product result will tell you if you are looking at the tree "from under" or not (if the dot is negative and also with small positive values if vectors are normalized). You can disable the trees that are looked-at "by under"; as the planet is a sphere, it should disable half of the trees, being as good as an occluder. This involve a little knowledge of scripting and maths, I don't have tome to write the code but maybe someone here can help.
Thanks guy! I make a distance between my Player and Tree and I can disable Tree renderer when Player is away from Tree! :) So that was simple and it's working :D Thanks again.
Answer by tigertrussell · Mar 20, 2015 at 03:46 PM
"Removed objects as requested." Sorry. Had to make a bug-resolution joke.
You should look into Occlusion Culling, I think.
How can I use OC with my runtime created trees? Can you give me code maybe?
I've never set it up myself; it only just became free due to Unity 5.
Answer by Nitin_jain · Mar 20, 2015 at 05:03 PM
I think you should check it out about Level of Detail (LOD) which may be solve you problem or change your approach.