#How do I have one Entity accurately sync with another in Netcode?

1 messages · Page 1 of 1 (latest)

late prairie
#

Let's say I have a player character running around using Rival (aka, Character Controller), and I want a separate Entity to float above my head. We'll say, a balloon. I don't want the balloon to lag behind me, or "look jank" or jitter.

Let's also assume the player character is either "predicted" or "owner predicted" in Netcode.

Would my balloon also need to be set as "predicted/owner predicted"?

How would I write a system to properly synchronize that balloon so that it is always above my player character's head?

paper quail
#

Unless the exact position of the balloon is critical for a consistent multiplayer experience this doesn't need to touch netcode at all.

Write a system that updates after the player has updated, and keep a rolling average of your target Entity's transform over the last N frames where N is like 2-10, adjusted to taste.

Have the balloon update against the rolling average rather than the absolute position. If you want it to be really smooth, clamp its acceleration or velocity to values close to the players to ensure it doesn't jump too much on network hiccups