Repository navigation
Open
Labels
contributor friendlythis issue is limited in scope and/or knowledge of Cubyz internals, good for newcomersexperimentala feature or idea that will require lots of experimentationphysicsgame physics stuffrefactorshuffle code around
Milestone
Description
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
Metadata
Metadata
Assignees
Labels
contributor friendlythis issue is limited in scope and/or knowledge of Cubyz internals, good for newcomersexperimentala feature or idea that will require lots of experimentationphysicsgame physics stuffrefactorshuffle code around
Activity
Argmaster commentedon Jul 31, 2025
Where does ECS (or anything alike) fit in this plan?
(Sorry for closing, my phone keyboard is annoying for some reason)
IntegratedQuantum commentedon Jul 31, 2025
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.
Argmaster commentedon Jul 31, 2025
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.
Argmaster commentedon Jul 31, 2025
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?
IntegratedQuantum commentedon Jul 31, 2025
These are all unrelated questions. This issue is just about the core physics update functions.
codemob-dev commentedon Aug 7, 2025
Would this mean that moving quickly horizontally then hitting a wall would cause fall damage?
ikabod-kee commentedon Aug 7, 2025
Ever heard of G force?
codemob-dev commentedon Aug 8, 2025
Yeah
9 remaining items
codemob-dev commentedon Aug 17, 2025
Does it make sense to move physics out of
game.zig?IntegratedQuantum commentedon Aug 17, 2025
Yes, but if you do so, then please make it as a separate PR, makes reviewing easier
Move physics to a separate file (#1775)
Split and generalize physics.calculateProperties() (#2934)
Split calculateMotion out of physics.update (#2964)
Split calculateEyeMovement out of physics.update (#2996)
Split calculateEyeMovement out of physics.update (PixelGuys#2996)
Split calculateWallCollision out of physics.update (#3033)
Move stepping related eye movement calculations into calculateEyeMove…
Split vertical collision functions out of physics.update (#3042)