Skip to content

Commit

Permalink
doc: BaseNetInput guide
Browse files Browse the repository at this point in the history
  • Loading branch information
elementbound committed Nov 20, 2023
1 parent 1b5205d commit 7d73d0b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 15 deletions.
12 changes: 0 additions & 12 deletions addons/netfox.extras/base-net-input.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@ extends Node
class_name BaseNetInput

## Base class for Input nodes used with rollback.
##
## During rollback, multiple logical ticks are simulated in the span of a single
## actual tick. Since these are just logical ticks, no actual input arrives
## during them from the input devices.
##
## The solution is to gather input before the tick loop, and use that input for
## any new ticks simulated during the rollback.
##
## This class provides a layer of convenience, since the only thing to do here
## is to implement the [code]_gather[/code] method. This method is responsible
## for setting all the properties that you have specified in [RollbackSynchronizer]
## as input.

func _ready():
NetworkTime.before_tick_loop.connect(func():
Expand Down
2 changes: 1 addition & 1 deletion addons/netfox.extras/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="netfox.extras"
description="Game-specific utilities for Netfox"
author="Tamas Galffy"
version="0.15.11"
version="0.15.12"
script="netfox-extras.gd"
2 changes: 1 addition & 1 deletion addons/netfox.noray/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="netfox.noray"
description="Bulletproof your connectivity with noray integration for netfox"
author="Tamas Galffy"
version="0.15.11"
version="0.15.12"
script="netfox-noray.gd"
2 changes: 1 addition & 1 deletion addons/netfox/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="netfox"
description="A higher-level networking addon with rollback support"
author="Tamas Galffy"
version="0.15.11"
version="0.15.12"
script="netfox.gd"
30 changes: 30 additions & 0 deletions docs/netfox.extras/guides/base-net-input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# BaseNetInput

Base class for Input nodes used with rollback.

During rollback, multiple logical ticks are simulated in the span of a single
network tick. Since these are just logical ticks, no actual input arrives during
them from the input devices.

The solution is to gather input before the tick loop, and use that input for
any new ticks simulated during the rollback.

## Gathering input

This class provides a virtual `_gather` method that you can override. Set the
variables configured in [RollbackSynchronizer] in your own implementation:

```gdscript
extends BaseNetInput
var movement: Vector3 = Vector3.ZERO
func _gather():
movement = Vector3(
Input.get_axis("move_west", "move_east"),
0,
Input.get_axis("move_north", "move_south")
)
```

[RollbackSynchronizer]: ../../netfox/nodes/rollback-synchronizer.md
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ nav:
- Guides:
- 'netfox.noray/guides/noray.md'
- 'netfox.noray/guides/packet-handshake.md'
- netfox.extras:
- Guides:
- 'netfox.extras/guides/base-net-input.md'

0 comments on commit 7d73d0b

Please sign in to comment.