Please help in optimizing a project!

I’m making a game, but it’s really laggy. I think, the problem is in some high-poly models. Could anybody help me with a script I will attach to them, that will turn off their renderer while they are far enough? I’m not strong in programming, but it should be something like player, mytransform, maxdistance and distance variables, if distance between the player and the object is more than maxdistance, turn off the renderer, else turn on. Thanks in advance!

If you have Unity Pro, you should use LODGroup Component to cull your high-poly models when they are far away :

Just attach this component to your object, keep only one level of detail and assign your renderer to it.

If you don’t have Unity Pro, the solution by Manco Capac seems right to me. I would personaly use a coroutines to do some verifications over the time.