-
-
Notifications
You must be signed in to change notification settings - Fork 60
Adding nodes with a RollbackSynchronizer causes resimulation from tick -1 #175
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
I encountered this issue while implementing periodic spawns of rollback-aware NPCs : each new RollbackSynchronizer still has a _latest_state set to -1 by the time _before_loop is first called, causing the _resim_from variable to be -1 for the corresponding _rollback call and thus resimulating everything from the start of the game (or history size, I didn't check, but it was tanking my FPS hard).
I worked around this by adding a _record_initial_tick function and calling it from process_settings as follows:
func _record_initial_tick(tick: int):
# Broadcast state we own
if not _auth_state_props.is_empty():
var initial_state = {}
for property in _auth_state_props:
initial_state[property.to_string()] = property.get_value()
if initial_state.size() > 0:
_latest_state = max(_latest_state, tick)
_states[tick] = PropertySnapshot.merge(_states.get(tick, {}), initial_state)
# Record state for specified tick ( current + 1 )
if not _record_state_props.is_empty() and tick > _latest_state:
_states[tick] = PropertySnapshot.extract(_record_state_props)
It's more of a hack at this point but it works. I would be interested if there were a preferred solution to this.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers