Hi. I have a performance problem with hitbox implementation.
In my FPS project I have 100 NPC. Shooting is implemented via hitscan traces. I use my custom hitbox for hit detection. It is just UBoxComponent, I create several hitboxes for each NPC and attach them to sekeletal mesh bones (two for leg, two for arm, for body, for head…).
Hitbox collision profile configured for QueryOnly and ignore all but Hitscan channel.
What I see:
In current implementation game has 50-60 fps (too low), without any hitscan traces;
If I fully disable hitbox collision (configure profile for No collision) - I get 120 fps;
Next test - enable QueryOnly, but set all channels ignored - again 50-60 fps.
What am I doing wrong? I found another approach - using Physical asset. But it requires higher performance (capsules vs boxes), doesn’t it? I tried to replace hitboxes by PA and got the same 50-60 fps.
Why do hitboxes consume performance even with all channels ignored? What is the right way to implement hitboxes?
Found temporary workaround - attached all hitboxes to root component (capsule). Yes, they are not moving, but animations are simple static locations don’t metter. In static mode hitboxes don’t consume performance (I don’t know why).
Why not turn off collision for all your boxes and use one big hitbox or the character capsule itself, and once you get hit by a trace, turn on collision for all those boxes and do the trace again see which box is hit and then turn them back off.