Hi everyone,
I’m trying to make a minecraft based game, so it needs terrain generation and stuff…
To prevent lag because of the amount of cubes i tried to use renderer.enabled to disable the meshes that the player can’t see.(the cubes are made of planes, not just a cube), the problem is that after the mesh renderer was disabled, when i look on the disabled objct it won’t enable the mesh renderer anymore…
This is the code:
var PlaneMesh : MeshRenderer;
function Update() {
if (renderer.isVisible) {
PlaneMesh.enabled = true;
} else {
PlaneMesh.enabled = false;
}
}
I’ve looked on the answers and searched on the forum but nothing helped me.
P.S. The terrain is generated from a prefab which is made of 6 planes to make a cube, every plane has the script attached.
Edit: Forgot to say that even if the camera is pointed on the obj. and i try to enable the mesh renderer in the inspector it won’t enable anyway…