Skip to content

Added docs for is_fresh and updated screenshot#263

Merged
elementbound merged 5 commits intofoxssake:mainfrom
albertok:fix-228-is_fresh_docs
Sep 10, 2024
Merged

Added docs for is_fresh and updated screenshot#263
elementbound merged 5 commits intofoxssake:mainfrom
albertok:fix-228-is_fresh_docs

Conversation

@albertok
Copy link
Copy Markdown
Contributor

#228

Added documentation for how is_fresh can be used.

@TheYellowArchitect
Copy link
Copy Markdown
Contributor

TheYellowArchitect commented Aug 29, 2024

The updated screenshot has input_redundancy and input_batch_count in the same project settings, because godot 4.1 doesn't hot-reload a plugin's variables, so a rename shows the same variable 2 times in 4.1 until you reload the project

As for is_fresh, I think it triggers only once a (rewindable) node starts rollback, so for activating weapon SFX, it works only if you place it on the projectile itself

Example code of forest brawler

func _rollback_tick(delta: float, tick: int, is_fresh: bool):
	# Respawn
	if tick == respawn_tick:
		_snap_to_spawn()
		velocity = Vector3.ZERO
		last_hit_tick = -1
		
		if is_fresh:
			GameEvents.on_brawler_respawn.emit(self)


## Single fire events

The first time a tick is processed, the `is_fresh` parameter is set to `true`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would suggest the following replacement for this line:
"In the first rollback tick processed for a node, the is_fresh parameter is set to true."

@albertok
Copy link
Copy Markdown
Contributor Author

The updated screenshot has input_redundancy and input_batch_count in the same project settings, because godot 4.1 doesn't hot-reload a plugin's variables, so a rename shows the same variable 2 times in 4.1 until you reload the project

As for is_fresh, I think it triggers only once a (rewindable) node starts rollback, so for activating weapon SFX, it works only if you place it on the projectile itself

Example code of forest brawler

func _rollback_tick(delta: float, tick: int, is_fresh: bool):
	# Respawn
	if tick == respawn_tick:
		_snap_to_spawn()
		velocity = Vector3.ZERO
		last_hit_tick = -1
		
		if is_fresh:
			GameEvents.on_brawler_respawn.emit(self)

Good catch @TheYellowArchitect . Screenshot updated!

is_fresh is definitely always true when a tick is first processed as its set and emitted from _process_tick.

flow is here: https://foxssake.github.io/netfox/netfox/guides/network-rollback/

I did some testing on both a single and multi client game and they worked as expected.

Observed by adding a log line at the start of a rollback tick function

print("peer: ", str(multiplayer.get_unique_id()), " - node: " ,name, " processing tick ", str(tick), " is fresh " , str(is_fresh))

@elementbound
Copy link
Copy Markdown
Contributor

Added a minor commit, wrapping docs to 80 chars. I'll have to document this convention somewhere 🙂

Not approving yet, due to the naming thing with #252

@albertok
Copy link
Copy Markdown
Contributor Author

albertok commented Sep 4, 2024

@elementbound removed the screenshot on this one to unblock

@elementbound
Copy link
Copy Markdown
Contributor

@albertok kudos!

@elementbound elementbound merged commit 44749f0 into foxssake:main Sep 10, 2024
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