Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Allocating particles at the start of the game to prevent lags on creation
#2
(28-05-2024, 02:00 PM)bozdo Wrote: In my game player is creating softbodies in runtime. Now, when it happens game lags a little. I assume its happens because at the moment of softbody creation obi solver does not have needed amount of particles and it creates new ones.

Hi!

When you add an actor to a solver and the current list of particles is not long enough, the list is resized. This is just a list allocating memory internally, shouldn't be noticeable at all. Is this measurable in the profiler?

(28-05-2024, 02:00 PM)bozdo Wrote: My current solution is to instantiate softbodies at the start and after 1-2 frames release those softbodies. This way solver is creating needed particles and game does not lag on creation of new softbodies

If this only happens in-editor, it could be that you're using async compilation with Burst which will cause the compiler to compile your code at runtime, when it is about to be used. This would explain why creating a few softbodies and then releasing them prevents the hiccup. The solution in this case would be to enable synchronous compilation: Jobs->Burst->Synchronous compilation.

It could also be shader compilation, if the shader used by your softbodies hasn't been used before.
Reply


Messages In This Thread
RE: Allocating particles at the start of the game to prevent lags on creation - by josemendez - 03-06-2024, 09:54 AM