admin管理员组文章数量:1414908
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.
Share Improve this question asked Feb 23 at 9:56 LimeSpeedCrystalLimeSpeedCrystal 12 bronze badges 1 |1 Answer
Reset to default 0Your game is still keeping too many entities active in memory and performing updates on them.
本文标签: Python Ursina way to disable entities far away to decrease the lagStack Overflow
版权声明:本文标题:Python Ursina: way to disable entities far away to decrease the lag? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745158633a2645326.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
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