When I scroll the mouse wheel up, the mesh at a certain distance from me gets removed from the level.
And when I scroll the mouse wheel down, the same mesh appears back at exactly the same location from where it was removed earlier.
Basically:
Scroll Up → Mesh removed (at set distance)
Scroll Down → Mesh reappears (at same spot)
Not sure this is a question but couple of ways to achieve depending on what you trying to do.
Assuming this is a single player thing
- You create an event on you player that broadcasts mouse scroll distance accumulated, after a number is reached event occurs as true, and listeners hide themselves. You need to listen these on actors.
- You can simply use a cull distance volume on your actors and they will stop rendering when a certain distance from camera reached.
- You can use a view frustrum on camera that will do tha same thing.
There are many things for performance optimization and rendering in the engine. You can access details about culling from here
However if this is not what you are looking for, try to describe the problem in more detail, like if you really want to destroy and spawn objects for some reason.