Skip to content

feat: Rewindable Actions#394

Merged
elementbound merged 24 commits intomainfrom
feat/rewindable-action
Mar 18, 2025
Merged

feat: Rewindable Actions#394
elementbound merged 24 commits intomainfrom
feat/rewindable-action

Conversation

@elementbound
Copy link
Copy Markdown
Contributor

@elementbound elementbound commented Jan 26, 2025

Adds a node that synchronizes events that may or may not happen during specific ticks in the rollback loop. Together with Mutations, it can be used to implement weapon firing fully as part of the rollback loop:

  1. Client records input to fire at tick #X
  2. Client simulates firing at tick #X, recording the fact with RewindableAction
  3. Input arrives at the server
  4. Server simulates firing at tick #X, recording the fact with RewindableAction
  5. RewindableAction sends a list of ticks where firing was confirmed
  6. Client applies changes and resimulates as needed

TODOs:

  • Hit SFX
  • Separate FPS examples with NetworkHitscanWeapon3D and RewindableAction
  • Docs
  • Mark as experimental before merge
  • Icon
  • Bump version

@elementbound elementbound marked this pull request as ready for review March 11, 2025 21:13
@elementbound elementbound force-pushed the feat/rewindable-action branch from fa8b839 to d0ae604 Compare March 12, 2025 20:30
Copy link
Copy Markdown
Collaborator

@DustieDog DustieDog left a comment

Choose a reason for hiding this comment

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

Overall it feels like a good start to rewindable actions, though based of Discord discussions, I'm not sure if it'd be a good idea to include this in a feature release until more testing/development is done, even with the experimental tag.

Having mutations make an appearance in core code has me uneasy regarding #383, namely that a more robust rollback system may be increasingly hard to implement in the future. For this PR it shouldn't be an issue, but I would say this bumps up the priority on getting that bug fixed before more new features are added.

This PR seems fine to me pending resolution of the comments.

Comment on lines +20 to +21
var _state_changes: Dictionary = {}
var _queued_changes: Dictionary = {}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Until we're able to update to statically typed dictionaries in v2, can we comment all dictionaries with their intended data structure for readability?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

var _has_confirmed: bool = false
var _has_cancelled: bool = false

var _context: Dictionary = {}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same as above regarding dictionary typing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

_: return "?"

## Toggles the action for a given [param tick]
func toggle(state: bool, tick: int = NetworkRollback.tick) -> void:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

toggle() is confusing, as you're setting the value of state instead of actually toggling it.

state is confusing as it typically refers to states elsewhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed both, though "X is confusing, it usually refers to X" didn't give me much understanding on the specifics 😄

@elementbound elementbound merged commit 0eae257 into main Mar 18, 2025
1 check passed
@elementbound elementbound deleted the feat/rewindable-action branch March 18, 2025 16:05
@TheYellowArchitect
Copy link
Copy Markdown
Contributor

Adds a node that synchronizes events that may or may not happen during specific ticks in the rollback loop. Together with Mutations, it can be used to implement weapon firing fully as part of the rollback loop

Does this make rollback projectiles spawned by weapons, possible?

@elementbound
Copy link
Copy Markdown
Contributor Author

@TheYellowArchitect it's part of the puzzle

  • Weapon firing can now be tracked in the rollback loop - feat: Rewindable Actions #394
  • Projectiles need to participate in the rollback loop, but without actually synchronizing state - PredictiveSynchronizer #374
  • We need a system to handle things existing in certain ticks and not in others, e.g. a projectile is spawned in 75, if we rewind to 72 it doesn't exist yet, and we can actually free the node once there's no way we'll rewind to a tick it has existed - TBA

@TheYellowArchitect
Copy link
Copy Markdown
Contributor

TheYellowArchitect commented Apr 24, 2025

I am very happy to hear it :)
I am inactive, chipping away at my own project, but I do check my emails every week and gleefully read those netfox issues/PRs and it does make me happy. What you are building, and the level it has reached, how few programmers can build? I surely cannot, it's hard. Yet it's free and open-source, and I am grateful for that. God bless you.

@elementbound
Copy link
Copy Markdown
Contributor Author

Thanks @TheYellowArchitect, your support is much appreciated!

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.

3 participants