Skip to content

Conversation

@albertok
Copy link
Contributor

@albertok albertok commented Mar 26, 2025

Helper classes for supporting physics stepping and rollback.

Auto-stepping is disabled and taken over by the netfox loop.

Physics implementations supported:

Progress

  • bass classes
  • docs
  • disable physics drivers on build

Closes #265

@albertok albertok changed the title Stepping Physics with Rapier Stepping Physics with Rollback Mar 28, 2025
@elementbound
Copy link
Contributor

Added a PhysicsDriverToggle implementation - they show up in the editor under Project > Tools, and they can check whether the toggled physics driver is even available:

image
image

@albertok
Copy link
Contributor Author

Nice work on the toggles @elementbound

I havent forgottten about this PR, just that time of year where I'm traveling a bit and don't get as much time to work on things.

Working on a RollbackSynchronizer Player driven RigidBody at the moment. It's a bit tricky as the pattern is a little different to what you would do with a CharacterBody.

Generally movement is all self contained in rollback_tick. When dealing with RigidBodies we need to let all RigidBodies take in what forces they will have, run the physics simulation for a step and then save the snapshots.

@albertok albertok marked this pull request as ready for review April 25, 2025 11:52
Copy link
Contributor

@kumpmati kumpmati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed that a CharacterBody's collider transform doesn't ever update unless force_update_transform is called, resulting in 'ghost' colliders. Not sure if there's a more elegant solution, but this works.

From my testing all the relevant CharacterBody transforms need to be updated on both _snapshot_space and _rollback_space, otherwise the collider might skip an update occasionally when the game window loses focus 🤷

@kumpmati
Copy link
Contributor

kumpmati commented May 5, 2025

Rapier seems to have a bunch of collision issues for me, but these might not be fixable in the rollback code:

  1. With rollback_space enabled in the driver, CharacterBody no longer collides with Areas or other CharacterBodies at all
  2. RigidBodies go through the floor in 3D

Here's the project I used to test these out: https://github.com/kumpmati/netfox-physics-rollback-test

@albertok
Copy link
Contributor Author

albertok commented May 6, 2025

@kumpmati Thanks for picking up on the 2D and CharacterBody issues.

Still looking into all its variations. Its mentioned here also:
godotengine/godot#76462 (comment)

Rapier seems to have a bunch of collision issues for me, but these might not be fixable in the rollback code:

Yeah, Rapier has its own issues. Collision seems to be spotty unless the surface is really thick.

func step_physics(_delta: float) -> void:
# Break up physics into smaller steps if needed
var frac_delta = _delta / physics_factor
var rollback_participants = get_tree().get_nodes_in_group("network_rigid_body")
Copy link
Contributor

@kumpmati kumpmati May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_tree().get_nodes_in_group(...) crashes the game if the scene with the driver is reloaded, since the driver is removed from the tree momentarily.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made sure that the signal handlers are disconnected if the node is not in the tree

@elementbound elementbound merged commit 2743c6a into foxssake:main Jun 16, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No physics applied to RigidBody3D when TickInterpolator also active

3 participants