I wouldn't call it much of a problem, but it really affects a project I'm working on. Now, I do understand that running a Minecraft clone with 1900 blocks isn't a good idea if you want high FPS, but the problem is that it's just 3 layers of blocks on a 25x25 world, meaning I'll probably encounter FPS 5 times lower in the future. My question is: Is there any kind of property, or way to disable the entities when they're far away.
I've tried this:
for block in blocks:
if distance(player, block) > 10:
block.disable()
else:
block.enable()
But this makes the game lag a lot as well, since it checks every block several times a second. My next idea was to run that every 60 frames, but the blocks being disabled doesn't actually seem to increase the FPS. I've tried using a mesh but I'm pretty sure that I cannot divide it back into blocks, and since this is a MC clone, that's a must have for the game. And also, there's a similar post/question where most of the answers are talking about meshes. Lastly, yes, I have in fact tried this code and I currently still have it in the program:
camera.clip_plane_far = 10
What I tried, what I expected and what actually happened:
Tried to render lots of entities at once with limited render distance, expected it to not lag a lot, it lagged a lot.
I wouldn't call it much of a problem, but it really affects a project I'm working on. Now, I do understand that running a Minecraft clone with 1900 blocks isn't a good idea if you want high FPS, but the problem is that it's just 3 layers of blocks on a 25x25 world, meaning I'll probably encounter FPS 5 times lower in the future. My question is: Is there any kind of property, or way to disable the entities when they're far away.
I've tried this:
for block in blocks:
if distance(player, block) > 10:
block.disable()
else:
block.enable()
But this makes the game lag a lot as well, since it checks every block several times a second. My next idea was to run that every 60 frames, but the blocks being disabled doesn't actually seem to increase the FPS. I've tried using a mesh but I'm pretty sure that I cannot divide it back into blocks, and since this is a MC clone, that's a must have for the game. And also, there's a similar post/question where most of the answers are talking about meshes. Lastly, yes, I have in fact tried this code and I currently still have it in the program:
camera.clip_plane_far = 10
What I tried, what I expected and what actually happened:
Tried to render lots of entities at once with limited render distance, expected it to not lag a lot, it lagged a lot.
Your game is still keeping too many entities active in memory and performing updates on them.
quads
with specified parent, checking if two overlap, removing both of them andparentbine()
the resulting shape. If you need to destroy the blocks, you can check out vertices of mesh and reduce it iny
direction, the reverse for adding a block. – Tanay Commented Apr 8 at 16:35