Skip to content

Conversation

@JSLegendDev
Copy link
Contributor

Someone mentioned under my KAPLAY in 5 mins video that the performance of the shooter example would degrade after 20s if they increased the trash spawn rate to 0.1.

After investigation, I noticed that the offscreen component was not being used, therefore trash game objects would not be destroyed once they fall outside the screen. Since we continually add trash game objects in this game, this would lead to degraded performance over time.

The fix is simple, use the offscreen() component.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 13, 2025

Open in StackBlitz

npm i https://pkg.pr.new/kaplayjs/kaplay@875

commit: 6ae8202

@awulkan
Copy link

awulkan commented Aug 14, 2025

That someone was me. 🙂
Implementing this change didn't fix my performance problems, but it still feels like a good addition to the demo.

Copy link
Member

@mflerackers mflerackers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can remove the old destroy code, and add the collision ignore rules

@lajbel lajbel changed the title Perf optimization for the shooter game kaplayground example fix: perf optimization for the shooter game kaplayground example Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants