(Solved) Request for physics engine behavior explanation

Can someone more experienced with game and physics engines explain me this behavior.
Lets say we have some game object file with collision object of type trigger and some shape and different group and mask (as example, “friend” and “enemy”).
If we spawn with factory a lot of such objects (1000+) where theirs shapes intersect a lot (like placing them in one point) it impacts fps much much more compared to when they are not intersecting.

So the questions are:

  1. Why they are detecting each other even though they are belong to one group “friend” and detect completely different “enemy”? And why intersection impact it that much?
  2. Profiler detects that most of the time is spent on “Kinematic update”, even though we have trigger type collision object. Why?

Hi!

  1. The physics engines do the filtering after the broad phase and narrow phase intersection tests.
    So, performance is depending on number of objects in each simulation island.

  2. We control the kinematic objects using the GO’s position.
    Also, if the physics.allow_dynamic_transforms is set, we update bodies that are not static type.

1 Like

Why? Is it generally faster, and this example just worse case scenario?

Yes, it would have to find out all possible types of mask combinations, and then do collision checks for them all. Then combine them, and solve the dynamics. It would be a lot of work, and I’m not sure it’d be correct in the end, as you want them all resolve collisions at the same time, not group by group.

If you’re not using this feature, you can test turning it off, to see if that helps.

I don’t see any at least significant difference, and most time is still spent on “collisionobjectc->StepWorld2D->UpdateKinematic”.

It was just tests, definitely would not spawn objects, especially that much, in the same place in a real project.

Thanks, for the answer.

1 Like