Best way to apply melee damage system

Hi! I was creating a melee damage system and thought that the best way is to make a sphere trace with timer to execute the code with animation and I encountered a problem. This system depends on FPS. What I mean is that if you have 140 FPS then you will have 4-6 spheres, with 60 FPS 3-4 spheres and with 30 FPS 2. I don’t think that it’s a right thing to do since if you have 30 FPS you can’t even hit the enemy.

140 FPS

60 FPS

30 FPS

Went on youtube to find another system but seems like everybody does it the same way
Thanks for reading!

So the only thing I came up with is to just create a sphere in front of the character to

15 FPS

I don’t know how this is handled by professionals but I don’t know how else to do it

Typically, you will use swept collisions around the weapons, and ideally around the targets, so there is no tunneling.
A swept collision has “distance” and it will be “longer” if the frame rate is lower, so it will still impact/detect whatever is in the way.
Also, the collision primitive should probably be built into the weapon and run every tick with the physics engine, generating hit or overlap events, rather than trying to do separate detections on a timer.

So I had this system you are talking about before and it was working fine and I’m not sure where but I read that this is very performance heavy to use overlaps with weapon and that you should always use tracing for tasks like this, don’t know why it stuck in my head but not sure how to handle it now :slight_smile:

If you’ll want 1000 soldiers, then, yes, overlaps will be a significant cost.

Then again, if something doesn’t have to work, it can be as low cost as you want it to, so comparing “a thing that doesn’t work and is cheap” to “a thing that works and I can afford” isn’t all that useful :slight_smile:

1 Like