Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions addons/netfox.extras/physics/network-rigid-body-2d.gd
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ func set_state(remote_state: Array) -> void:
## The physics engine will run its simulation during rollback_tick with other nodes
func _physics_rollback_tick(_delta, _tick):
pass

## Override to run once per network tick, before any physics sub-step
## Receives the full tick delta and the tick being simulated
func _before_physics_rollback_tick(_delta, _tick):
pass
5 changes: 5 additions & 0 deletions addons/netfox.extras/physics/network-rigid-body-3d.gd
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@ func set_state(remote_state: Array) -> void:
## The physics engine will run its simulation during rollback_tick with other nodes
func _physics_rollback_tick(_delta, _tick):
pass

## Override to run once per network tick, before any physics sub-step
## Receives the full tick delta and the tick being simulated
func _before_physics_rollback_tick(_delta, _tick):
pass
6 changes: 6 additions & 0 deletions addons/netfox.extras/physics/physics_driver.gd
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ func step_physics(delta: float, tick: int) -> 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")

# Run once per network tick, before any sub-step, with the full tick delta
for net_rigid_body in rollback_participants:
net_rigid_body._before_physics_rollback_tick(delta, tick)

for i in range(physics_factor):
# Run once per sub-step, with the sub-step's delta
for net_rigid_body in rollback_participants:
net_rigid_body._physics_rollback_tick(frac_delta, tick)

Expand Down