Horrible framedrops, maybe caused by RigidBody2Ds or physics

Godot Version

4.6.2

Question

Hello!
I'm fairly new to coding, and I'm very fond of pinball, so I'm trying to make a Pinball mobile game. So far it's going pretty good and all my central physical systems work pretty well (flippers, ball etc.)

I wanted a slight "shatter" effect when the player picks up a star - it turns into 4 little balls that bounce around for a bit then disappear (and are queue_freed()). For some reason, whenever I pick up a star, my game lags.

I really don't want to give up on this effect because it's very cool and the shards make tiny sounds when they hit walls and stuff... is there any way I can reduce the lag or optimize the game?

attached is an image of the profiler... you can probably guess when I've picked up a star. I should also add, the game is running at 120FPS;

Let’s see the exact time breakdown of the largest spike.

Apologies for the late response - apparently I had notifications off :sweat_smile:
I ran it again, here’s a breakdown of the largest spike when picking up a star;
And thanks for your reply!

physics2D seems fine. scroll a bit down on that box. what does it say on “script functions” and “audio thread”?

Both “Audio Thread” and “Script Functions” seem fine. I checked it again and the framedrops aren’t as bad… not sure what changed :sweat_smile:
thanks for the help either way…

Are you doing this stuff on a battery-powered device? Sometimes i get frame drops because the power saver mode downclocked my CPU to oblivion and any notification or minor background task makes it miss the physics process deadline.

Actually, I am; I’m working on a MacBook Pro. The frame drops really are kind of inconsistent. I hope when I finally export it to iOS I can see if the issue persists, but I’ve never done this before and Apple certainly did not make it easy… one of the few times I’m a disappointed I don’t have an android phone :unamused_face:

Either way, thanks for the response. I assume if I try it on my phone and I’m still getting drops I’ll post here again or something