Guribo / UdonVehicleSync

Smooth, predictive synchronization for rigidbody based vehicles for VRChat worlds.
https://guribo.github.io/TLP
MIT License
3 stars 0 forks source link
circular-prediction linear-prediction prediction synchronization udon udonsharp vrchat vrchat-sdk3 vrchat-worlds

Udon Vehicle Synchronization

Total downloads

A predictive, smooth synchronization implementation for non-kinematic RigidBodies.

Highly experimental and to be considered unstable as it is very much subject to change!

Preview

Features

  1. Automatic respawn if below certain height
  2. Freely adjustable send rate, smoothing and responsiveness
  3. VERY accurate timing across different network and player conditions
    1. Positional error at supersonic speeds is almost negligible
    2. Time drift reduced to be almost invisible
    3. No rubber banding in un-obstructed flight
      1. Note that we are still dealing with prediction, so overshoot on rapid velocity changes is still present, but minimized
  4. Dynamic send rate based on current movement and its prediction
    1. Sender is determining if and when it needs to send the next packet based on the last packet it sent
  5. Dynamically adjustable prediction amount that allows reducing prediction and going back into a replay mode
    1. WORK IN PROGRESS currently not smooth at all
    2. Good option maybe for spectators

Future development

  1. Find a way to allow e.g. midair contact between sender and receivers without Unity physics freaking out
  2. Performance improvements (Udon 2?)
  3. Simplify setup
  4. Implement a kind of local simulation of collision to prevent overshoot and increase immersion

Installation

  1. Install/Add VRChat World SDK 3.7 to your project
  2. Install/Add CyanPlayerObjectPool to your project: https://cyanlaser.github.io/CyanPlayerObjectPool/
  3. Install/Add TLP UdonVehicleSync to your project: https://guribo.github.io/TLP/

Setup

  1. Add the following prefabs once to your scene:
    1. TLP_Essentials
    2. TLP_SyncOrigin
  2. For any RigidBody that shall be synchronized add the prefab TLP_UdonVehicleSync_WithSettingsTweaker to the scene (does not need to be attached to the object)
  3. Unpack the prefab (not completely!) and drag the contained SettingsTweaker GameObject somewhere so that it is no longer a child to the prefab or the Rigidbody
  4. Go through each object of the TLP_UdonVehicleSync_WithSettingsTweaker prefab and set references:
    1. TLP_UdonVehicleSync_WithSettingsTweaker/Sender:
      1. NetworkTime = TLP_NetworkTime prefab in the scene
    2. TLP_UdonVehicleSync_WithSettingsTweaker/Sender/VelocityProvider:
      1. RelativeTo = TLP_SyncOrigin (Transform of the prefab in the scene)
      2. ToTrack = RigidBody of the parent (object that shall be synchronized)
    3. TLP_UdonVehicleSync_WithSettingsTweaker/Receiver:
      1. NetworkTime = TLP_NetworkTime prefab in the scene
  5. Ensure that ownership of the Receiver GameObject is transferred correctly when another player takes control!

Execution order info

The owner reads and serializes the transform position in PostLateUpdate(). Other players deserialize the data and apply it in Update().

This means that ideally the owner will/should modify the transform position in either FixedUpdate(), Update() or LateUpdate() before it is sent to other players.

Versioning

This package is versioned using Semantic Version.

The used pattern MAJOR.MINOR.PATCH indicates:

  1. MAJOR version: incompatible API changes occurred
    • Implication: after updating backup, check and update your scenes/scripts as needed
  2. MINOR version: new functionality has been added in a backward compatible manner
    • Implication: after updating check and update your usages if needed
  3. PATCH version: backward compatible bug fixes were implemented
    • Implication: after updating remove potential workarounds you added

Changelog

All notable changes to this project will be documented in this file.

[2.2.0] - 2024-09-14

๐Ÿš€ Features

[2.1.1] - 2024-06-03

โš™๏ธ Miscellaneous Tasks

[2.1.0] - 2024-05-17

๐Ÿš€ Features

โš™๏ธ Miscellaneous Tasks

[2.0.1] - 2024-05-16

๐Ÿ› Bug Fixes

[2.0.0] - 2024-05-16

๐Ÿš€ Features

๐Ÿšœ Refactor

โš™๏ธ Miscellaneous Tasks

[1.1.0] - 2023-11-08

๐Ÿš€ Features

[1.0.0] - 2023-11-03

๐Ÿš€ Features

[0.0.0] - 2023-10-03

๐Ÿš€ Features

๐Ÿšœ Refactor

๐Ÿงช Testing

โš™๏ธ Miscellaneous Tasks