- Home /
¿can i draw Objects only when in a certain range around the Player?
hi there :b
You'll see... I have a level were you're walking thru a LOOOOONG Avenue full of Zombies & other physic objects like boxes, cars & stuff... it is at night so the player can't se anything beyond certain zone around him & zombies won't follow you until you can see them.... Problem is, there's a lot of stuff being draw, even if it's not visible yet. I don't really have performance troubles yet but anyways i wanna know if there's a way to only draw stuff like enemies & other objects when you get close to them.
was thinking about changing the clipping range of the camera but it also stop drawing buildings so it looks ugly (maybe could i apply the clipping range only to certain objects?) *also a friend of mine suggested me creating triggers to spawn objects while you're going thru the level, but as far as i have seen, this creates an awful little lag. *then i though about making spawners that creates zombies one by one, before you get close, but once the object is there, it still there & even if i could erase them, if the player goes back, the level would be empty...
Any ideas?
maybe i'm overthinking it too much & i'm just a beginner but i really wanna make it as flow & fast as i can
thanks you very much O:!
Answer by tanoshimi · Nov 24, 2013 at 09:09 PM
One approach would be to place your buildings on one layer and set the culling mask of a camera to render only that layer, using a far clipping plane. Then place all your other in-game objects (zombies, boxes, cars and stuff) on another layer and use a second camera to render that layer with a much closer clipping plane.
Answer by LudwigVK · Nov 26, 2013 at 07:01 PM
for anyone coming to this answer, i did what Tanoshimi suggested me; i used a Camera to render just the buildings & Skybox, then i used another to render other objects & put this as a child of the other camera. Problem then was that then i could see those objects even if they were behind buildings, i solved this by creating a script that when coming near to a certain range & therefore rendered, those objects were moved into the default layer so it was normally rendered, then when out of sight, they come back to the other Layer.
Your answer
Follow this Question
Related Questions
decrease draw call instantiated object 2 Answers
how to have object fall using random speed 0 Answers
Huge performance hit when spawning prefab with AI 1 Answer
Spawn single floor tile at mouse position 1 Answer
How To Random Range a Float? 2 Answers