DarkflameUniverse / DarkflameServer

The main repository for the Darkflame Universe Server Emulator project.
https://www.darkflameuniverse.org/
GNU Affero General Public License v3.0
629 stars 171 forks source link

ENH: Kinematics simulation for players who are moving at high velocities #734

Open EmosewaMC opened 1 year ago

EmosewaMC commented 1 year ago

Is your feature request related to a problem?

Yes. Currently, players are able to clip through certain planes due to their velocity being too high and being in front of the plane on 1 frame, and behind it the next frame. This can cause players to "clip" through death planes and other objects that use phantoms.

Describe the solution you'd like

The ideal solution would be if we are moving at or near maximum velocity, the server does a simulation of the player going through all points between the current one and the updated position to ensure that we do not miss triggering any points in between the two steps.

Repository breaking implications

Could cause the "land-shark problem" or cause phantoms to get collisions that are not happening, causing out of place deaths / poor timing for mission progression.

Describe alternatives you've considered

Currently we make the death plane twice as big in order to partially compensate for this.

Additional context

733

DarwinAnim8or commented 1 year ago

The way an issue such as this is typically resolved in physics engines, is to simply create a temporary shape that overlaps both frames' collision info.

IE: a box is on one side of a plane on frame 1, on the other side on frame 2. Solution: create a box that contains both of the boxes on both frames, and do a collision test with the plane on that.

This isn't the only solution, and may not be the most appropriate one either. I've forgotten by now, do we simulate velocity of players ? Does the physics engine run at the same framerate that worlds do?

EDIT:

Another thing to consider is that a world server could receive multiple position / velocity updates per frame, but only the last one is kept for collision checks on the start of the next frame. Perhaps the ideal solution is to just store all of the updates and run through all of them on the start of the next frame-- though I would imagine it'd impact performance a bit.

EmosewaMC commented 1 year ago

I dont think we simulate velocity of players at all. We just get their position from the client and put them at that position in the physics world. The physics engine does also run at the same tick rate of the server so if the physics world is stepped, the whole world is stepped.

Not sure of how to address this problem so my first suggestion was just to simulate the interpolated position with kinematics, however I am inexperienced with physics problems such as this and only have limited experience to talk from.

What do you think the best approach would be for addressing an issue such as this?