how would I make a object mesh renderer enable when came is looking at the cube, but the mesh renderer is not enabled at the time??
I assume you’re trying to optimize performance but it’s simply unnecessary. Unity as frustum culling built-in and always runs. No need to disable renderer when not visible by camera.
What you’re likely looking for is called Occlusion Culling, it’s a pro-only feature.
https://docs.unity3d.com/Documentation/Manual/OcclusionCulling.html
However if you’re using static cameras you can accomplish something similar via script.
wait a second. What about firing a raycast from the screen. say like 100 raycasts.and they be strait out the camera. they hit a collider, mesh turns on.
Nah, that would be way too expensive.
how so, and anyways how would I just d oit. In the long run it will help. ALso I have 2k cubes on a map and htat lags, that’s why I want to make my own occlusion culling.
Feel fre eto try it, goa head.
The amount of memory you’d be using by constantly firing that many raycasts would be just as lagging as the 2k cubes, if not more so. Also 2k cubes is an insane amount of cubes, it would be more efficient to find another way to accomplish your goal that doesn’t involve cubes but only visible faces. If you’re trying to do something similar to minecraft with cubes you need to be using occlusion culling or another method of only drawing the visible faces of the cubes.
dang. I am making a building game btw. it sucks I cant do it without lag :o
how would I make only certain faces show (Or if hit by a raycast, make that face invis)
Do a search for unity minecraft, many people have tackled this problem already and there are some decent solutions floating around out there.
I am having hard time finding them, but I am still looking.
2k cube doesn’t seems that much to me, that’s only 24k tri. I made some test for my game, with 1000 Planets, so 1000 spheres and that wasn’t lagging at all, i could maybe put 10k spheres or more (according to VRAM usage and such. Maybe your computer is not good enough or maybe that your developping for mobile. Or maybe that it’s lagging when all your cube are rendered at the same time on screen (like a zoom out view). And even in that case, i read that recommended tri count is 10 k per characters, average 4 Characters, + environment, so at least 50k tri rendered, wich is twice as big as your 2K cubes. So i guess trouble is from your computer.
My computer is quite average, but I would Like to make It so if my game does get bought in the future, people can play with little lag, and have a low grade comp
OnBecameVisible could work for you. Just enable renderers when a camera can actually see it and disable when it can’t.