https://github.com/eamonnmr/lerp-helper-godot-3
Class to make lerp based networking less copypasta intensive
https://github.com/eamonnmr/lerp-helper-godot-3
Last synced: 2 months ago
JSON representation
Class to make lerp based networking less copypasta intensive
- Host: GitHub
- URL: https://github.com/eamonnmr/lerp-helper-godot-3
- Owner: EamonnMR
- License: mit
- Created: 2021-11-19T15:11:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-19T15:20:18.000Z (over 3 years ago)
- Last Synced: 2025-02-13T23:37:30.626Z (4 months ago)
- Language: GDScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lerp-helper-godot-3
Class to make lerp based networking less copypasta intensiveSee:
https://www.youtube.com/watch?v=w2p0ugw3afs
and:
https://www.youtube.com/watch?v=XGyrKmOxLccThe gist of this class is that you'll be sending server state freeze-frames to your clients. It expects you to implement the following methods on a Client singleton (I might include this later):
Client.time: current time according to the client. This should be some time in the past to account for latency.
Client.get_net_frame_current(id): returns the net frame data of the most recent frame for this entity or nothing if no such data is available
Client.get_net_frame_last(id): ditto, but for one frame in the past.What's neat about this class is that it wraps the decision to interpolate or extrapolate and you can use it to directly update the values of the class you're using it on to the correct interpolated/extrapolated values like this:
```
func _physics_process(delta):
if is_network_master():
# Do server authoritative stuff
else:
var lerp_helper = LerpHelper.new(self, self.name)
if lerp_helper.can_lerp:
lerp_helper.lerp_member("member_name")
# ... etc
elif lerp_helper.can_extrapolate:
lerp_helper.extrapolate_member("other_member")
# ... etc
```
Which is nice.