#StaticBody3D adding shapes causes significant lag

1 messages · Page 1 of 1 (latest)

swift oak
#

I'm having severe performance issues when adding/removing collision shapes to StaticBody3D, I havent tested it with other physics bodies. But adding nodes at the same rate to a regular Node3D does not lag at all, but it absolutely tanks with StaticBody3D.

How would I get around this? I'm thinking maybe I can just add all the nodes in one go then just teleport them to where I need them to be instead of adding/removing dynamically. But I am making this post to maybe get advice on how I can optimize or potentially fix this another way.

First ss is the Node3D & second is the StaticBody3D

swift oak
#

teleporting the nodes does not fix the issue

zinc lotus
#

How are you instancing the nodes? What does the code look like?

#

Are you getting any errors?

#

And, does the lag happen with other physics bodies?

#

How many staticbodies are you removing and adding? What's the use-case?

#

Tbh the most important questions are how many nodes you are instancing & what you're trying to accomplish in the end

swift oak
zinc lotus
#

Why do you need to stream the nodes?

#

The situation that comes into my head is like an infinite-runner type game where the world is generated as you go

swift oak
#

i tried that, it causes extreme lag when trying to unload the world behind you with that many nodes

zinc lotus
#

...that was me trying to guess what your game is like

#

to have a clue as to why you need to stream the world :b

#

I can't really answer how you can get around the lag issue if I don't know you are doing this in the first place

#

unless the solution is something simple I can tell you w/o context, like "try using characterbody instead of statidbody"

full lodge
#

If you instantiate a new StaticBody3D instead of adding a collision shape to an existing StaticBody3D does it cause the same spike? Adding/removing anything from the "physics world" will result in some extra cycles

swift oak
#

Wow. Adding new static bodies instead of adding shapes to an existing static body is much faster, somehow??

My guess is that there is some extra work Godot is trying to do when resolving many shapes on a single body when adding another