Improved shot collision, possible FPS increase


#1

It irks me how shots can pass through enemies without harming them when the framerate is low, most notoriously when attacking test chests and such.

To fix this, I propose making the local player’s shots check collisions about or 30 or 20 times per second regardless of actual framerate and also checking the collisions of other players’ shots every other frame.
I’m not so good at explaining how that would work, so I’ll illustrate it with a gif and some pseudocode.


This gif depicts a level 1 sorc shooting, shown at 10 frames per second. The gaps between the shots at the top could easily fit a test chest, if one were inbetween the shots it would not get hit at all. The transparent shots at the bottom show where the bullet could’ve been if the framerate had been 30 fps.

How it works right now: (as I understand)

Every frame:
    For each shot visible from any source:
        Set the position of the shot, relative to where it was shot, using the time since it was shot
        Draw the shot
        Check whether the shot collides with anything

How I want it to work:

Make unimportant shots collide this frame? YES
Every frame:
    For each shot visible from any source:
        If the shot is the player's responsibility:
            Loop (amount of milliseconds since last frame, divided by ~33 ms)
                Check collision at wherever the shot should be at this inbetween frame
            Set the position of the shot etc.
        Else if unimportant shots should collide this frame or the shot was emitted by a monster:
            Set the position of the shot etc.
            Check whether the shot collides with anything
    For each shot visible from any source:
        Draw the shot
    If unimportant shots collide this frame, they don't next time, otherwise they do.

A possible downside of this would be seeing other players’ shots pass through walls, trees etc., but that’s not a concern because the server does not care what you think about others’ shots - it just looks ugly. Also a sanity check needs to be added for when the actual fps exceeds 30, otherwise this would make shots check collisions less often!

Hopefully I’ve made myself clear without sounding like the physical embodiment of autism bashing a keyboard. Thanks for reading and throw me an opinion!

Edit: I feel like I need to highlight that the fps increase is supposed to be from paying less attention to shots from other players. Thinking about it later, it seems that the best solution is to merge the massive amounts of damage indicators stationary enemies get, which is what makes the game lag in the first place. And that’d do nothing when you disable allied particles because there’s nothing to marginalize.


Projectile hit detection (spell bomb on test chest or avatar)
#2

You went into some nice detail to explain the problem I’ve always had.

I can’t participate in any event with more than 10 people because 99% of my shots are never registered giving me no loot ever.

But how would this affect performance? My performance is pretty bad (which is why this is such an issue for me) but would this reduce performance by a large margin?

When I experience this I usually drop from 15 - 20 fps to 0 - 5 fps, if this would allow me to get damage in for SB, but kept my frame rate at 7 - 10 I’d have the best love-hate relationship with this game.


#3

it looks like you’re trying to make the game make additional checks in between frames, instead of in the frame itself. not only do I think this is impossible, I’m pretty sure it would additionally reduce your fps even further. you can’t just magically make the game load things faster if the problem is actually that your computer can’t handle it.


#4

I am, indeed, trying to make the game make additional checks in a frame. The point is to backtrack and make sure there are no large gaps between collision checks. But I can’t do anything “in between frames”.

What I’m trying to evoke is something I heard a long time ago about iphones showing you a picture of the app you’re opening when you tap it, giving the impression that it has opened immediately, when it’s actually loading. I’m making the game seem faster, seem as if it had checked for collisions 30 times per second.


#5

First, love the effort put in.

But I think what you’re suggesting is simply not viable, though I suggest you seek the opinion of someone less inept than me.

A frame is a point in time and I don’t think you can do multiple checks in one frame. The game asks at each frame “is a projectile connecting with some entity?” but asking that more than once per frame is futile, because projectiles that didn’t hit anything in that frame before won’t have since hit something after.

Or am I completely misunderstanding lol, I have no coding knowledge so REEEE


#6

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.