Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delayed bomb explosion force #274

Open
TheYellowArchitect opened this issue Sep 4, 2024 · 0 comments
Open

Delayed bomb explosion force #274

TheYellowArchitect opened this issue Sep 4, 2024 · 0 comments

Comments

@TheYellowArchitect
Copy link
Contributor

TheYellowArchitect commented Sep 4, 2024

Feel free to close this issue as not planned.
If you run forest brawl with 150 ms delay (sudo tc qdisc add dev lo root netem delay 150ms), and have a client bomb a client (any player but the host), there is a noticeable delay before the pushback happens. 150 ms probably. So the bomb explodes, the VFX and SFX play out, but nothing happens to the player locally until 150 ms pass.

The lack of this feature (or is it a bug?) prevents netfox from being used for smooth melee combat.
For example, how can one implement a shove/push mechanic?

func _tick(tick):
	if birth_tick <= tick and tick < death_tick:
        for body in get_overlapping_bodies():
		var displaceable = _find_displaceable(body)
		if body.is_multiplayer_authority() and displaceable != null and NetworkRollback.is_simulated(body):
			var diff: Vector3 = body.global_position - global_position
			var f = clampf(1.0 / (1.0 + diff.length_squared()), 0.0, 1.0)
			diff.y = max(0, diff.y)
			displaceable.displace(diff.normalized() * strength * f * NetworkTime.ticktime)
		if body is BrawlerController and body != fired_by:
			body.register_hit(fired_by)

If I remove the checks which check for authority, so the client sets that body's position, and for server to later override, it overshoots then is corrected, which looks worse than the push delay of 150ms.

I don't know how one would solve this, but the only suggestion I can think of is have a local push force which is exclusively for local prediction, and this local push force is always 1/3rd of the actual force. With this, there will be instant push feedback once you hit a player with a bomb, and the server correction should lead to no artifacts.

for body in get_overlapping_bodies():
		var displaceable = _find_displaceable(body)
		if displaceable != null and NetworkRollback.is_simulated(body):
			var diff: Vector3 = body.global_position - global_position
			var f = clampf(1.0 / (1.0 + diff.length_squared()), 0.0, 1.0)
			diff.y = max(0, diff.y)
			if (not body.is_multiplayer_authority()):
				f = f / 3
			displaceable.displace(diff.normalized() * strength * f * NetworkTime.ticktime)
				
		if body is BrawlerController and body != fired_by:
			body.register_hit(fired_by)

The above works perfectly for the hit player, instead of everyone. In other words, the explosion push force has no delay for the player who was hit by it, but the delay persists for the player who threw the bomb. Even if I remove the authority check entirely.

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

No branches or pull requests

1 participant