Commit cad4b4c
fix: buffered linear interpolator jitter and exposing more properties (#3355)
After doing some testing I noticed a few anomalies with the updated
`BufferedLinearInterpolator<T>`. As it turns out, there are more than
one approaches a user might need depending upon what they are trying to
accomplish and each option really performs best when tweaking some
properties within the `BufferedLinearInterpolator<T>` that were not
completely exposed.
### Various options:
- You might want to enable, disable, or adjust the maximum interpolation
time of the last smooth lerp phase for each interpolator type.
- You might want to manually adjust the tick latency offset
(`NetworkTransform.InterpolationBufferTickOffset`) used depending upon
context.
- When using a client-server topology, you might want this to be set to
something like 0 or 1 (depending upon interpolator).
- You might want this value to be higher (like say +2-3 depending on
latency and interpolation type) on non-authority instances where the
authority is some other client and not the host/server.
### This PR renames `Lerp` to `LegacyLerp` and adds a 3rd new `Lerp`
interpolator type:
#### Lerp (new)
Uses a 1 to 2 phase approach that lerps towards the target, lerps
towards the next target (if one exists) ahead by 1 frame delta, blends
the two results, and (optionally) smooth the final value.
- The first phase lerps towards the current tick state update being
processed.
- The fourth phase (optional) performs a lerp smoothing where the
current respective transform value is lerped towards the result of the
first phase at a rate of 1.0f minus the max interpolation time.
## Changelog
- Added: `Lerp` interpolation type that still uses a lerp approach but
uses the new buffer consumption logic.
- Added: Property to enable or disable lerp smoothing for position,
rotation, and scale interpolators.
- Added: `NetworkTransform.InterpolationBufferTickOffset` static
property to provide users with a way to increase or decrease the time
marker where interpolators will pull state update from the queue.
- Fixed: Issue where the time delta that interpolators used would not be
properly updated during multiple fixed update invocations within the
same player loop frame.
- Changed: The original `Lerp` to be renamed to `LegacyLerp`.
## Testing and Documentation
- Includes integration test updates.
- Includes documentation for public API entry points.
- Includes updates to public documentation for `NetworkTransform`. (Will
be adding to
[PR-1443](Unity-Technologies/com.unity.multiplayer.docs#1443))
<!-- Uncomment and mark items off with a * if this PR deprecates any
API:
### Deprecated API
- [ ] An `[Obsolete]` attribute was added along with a `(RemovedAfter
yyyy-mm-dd)` entry.
- [ ] An [api updater] was added.
- [ ] Deprecation of the API is explained in the CHANGELOG.
- [ ] The users can understand why this API was removed and what they
should use instead.
-->
---------
Co-authored-by: Emma <[email protected]>1 parent 0e1ae7e commit cad4b4c
File tree
16 files changed
+910
-325
lines changed- com.unity.netcode.gameobjects
- Editor
- Runtime
- Components
- Interpolator
- Core
- Messaging/Messages
- Timing
- TestHelpers/Runtime
- Tests/Runtime
- NetworkTransform
- testproject/Assets/Tests/Runtime/NetworkTransform
16 files changed
+910
-325
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| |||
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| 25 | + | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
| |||
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| 46 | + | |
42 | 47 | | |
43 | | - | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
| |||
Lines changed: 26 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
| |||
77 | 80 | | |
78 | 81 | | |
79 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
80 | 88 | | |
81 | 89 | | |
82 | 90 | | |
| |||
198 | 206 | | |
199 | 207 | | |
200 | 208 | | |
201 | | - | |
202 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
203 | 212 | | |
204 | | - | |
205 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
206 | 218 | | |
207 | | - | |
208 | 219 | | |
| 220 | + | |
209 | 221 | | |
210 | 222 | | |
211 | 223 | | |
212 | 224 | | |
213 | | - | |
214 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
215 | 229 | | |
216 | | - | |
217 | 230 | | |
218 | | - | |
219 | 231 | | |
| 232 | + | |
220 | 233 | | |
221 | 234 | | |
222 | 235 | | |
223 | 236 | | |
224 | | - | |
225 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
226 | 241 | | |
227 | | - | |
228 | 242 | | |
229 | | - | |
230 | 243 | | |
| 244 | + | |
231 | 245 | | |
232 | 246 | | |
233 | 247 | | |
| |||
0 commit comments