Skip to content

The future of (surface) physics #1728

Open

Description

@IntegratedQuantum

The current physics system is a mess, and every new additions makes it worse. All the different effects (climbing, friction, bounciness, collision) don't interact well with each other.

Furthermore a lot of these effects should be 3 dimensional, while currently they only affect certain directions.

So I propose the following changes:

  • The update function should be split into smaller, easier understandable functions.
  • Physics should be simulated at a fixed framerate and interpolated if fps is higher.
  • On collision the collision system should register the force (Δv with "natural units" in the snaleverse)
  • Surface properties should be calculated on collision, since most effects (bounciness, friction) only apply when the body exerts a force onto the ground. This also makes these effects cheaper to calculate, since they only need to be calculated when the body actually collides.
  • All surface parameters are directional and can be (optionally!) specified as a direction vector in the files.
  • Some of these properties should be kept in memory until the next iteration. For example friction × Δv can be used to calculate the new acceleration based on the player inputs, without rechecking the area.
  • For climbing I think it would make sense to provide a separate physics parameter "grip" that allows the player to apply a force independent of friction × Δv. This would allow it to nicely integrate into the remaining systems.
  • For fall damage the Δv can be used to calculate the actual impact energy, which can be used to calculate fall damage.

requires AABBs #826

Activity

  1. added
    contributor friendly
    experimental
    physics
    on Jul 31, 2025
  2. Argmaster commented on Jul 31, 2025

    @Argmaster
    Collaborator

    Where does ECS (or anything alike) fit in this plan?
    (Sorry for closing, my phone keyboard is annoying for some reason)

  3. IntegratedQuantum commented on Jul 31, 2025

    @IntegratedQuantum
    MemberAuthor

    ECS is irrelevant. These functions consume physics constants and produce new ones, where these values come from or where they are stored or where the core physics function is called from doesn't matter.

  4. Argmaster commented on Jul 31, 2025

    @Argmaster
    Collaborator

    Well, it was more about where do we put this code (should it be inside systems or alike), but you already answered that - not necessarily inside ECS, but rather outside and ECS can call it if it needs to.

  5. Argmaster commented on Jul 31, 2025

    @Argmaster
    Collaborator

    Should the physics be client side, server side or some in-between? Is it time we start caring about lying clients?
    What if client can't keep up with physics tick speed?

  6. IntegratedQuantum commented on Jul 31, 2025

    @IntegratedQuantum
    MemberAuthor

    These are all unrelated questions. This issue is just about the core physics update functions.

  7. codemob-dev commented on Aug 7, 2025

    @codemob-dev
    Contributor

    For fall damage the Δv can be used to calculate the actual impact energy, which can be used to calculate fall damage.

    Would this mean that moving quickly horizontally then hitting a wall would cause fall damage?

  8. ikabod-kee commented on Aug 7, 2025

    @ikabod-kee
    Collaborator

    Would this mean that moving quickly horizontally then stopping would case fall damage?

    Ever heard of G force?

  9. codemob-dev commented on Aug 8, 2025

    @codemob-dev
    Contributor

    Ever heard of G force?

    Yeah

  10. 9 remaining items

  11. codemob-dev commented on Aug 17, 2025

    @codemob-dev
    Contributor

    Does it make sense to move physics out of game.zig?

  12. IntegratedQuantum commented on Aug 17, 2025

    @IntegratedQuantum
    MemberAuthor

    Yes, but if you do so, then please make it as a separate PR, makes reviewing easier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    contributor friendlyexperimentalphysicsrefactor

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions