Skip to main content

Position Sync

Position Sync World Preview

A simple PlayerObject prefab which saves each player's position and rotation, then restores them when they rejoin the world.

Visit the PositionSync Example World using the persistence-beta branch to try it for yourself!

Persistent worlds break if you create them on the VRChat website. Instead, create instances directly in VRChat.

Using the Example

In the VRChat Client:

  1. Join the world, move to a spot away from the Spawn point.
  2. Rejoin the world, you should be around the same position and rotation.

In the Unity Editor: Add the prefab: PositionSync to the scene, and done.

Importing the Example

Follow the steps below to add this example to your Unity project:

  1. Open the Example Central Window from the window from the Unity Editor Menu under "VRChat SDK > 🏠 Example Central"
  2. Find this prefab in the list or search for it by title (same as the title of this page).
  3. Press the "Import" button to import the Unitypackage into your project.

Technical Breakdown

If you are standing on the ground, the script will save your position and rotation every 0.5 seconds. Upon receiving the persistent data from the server, it will return you to the position you originally found yourself in.

Inspector Parameters

  • string Synced Position key - The key name for the position you want to use from PlayerData.
  • string Synced Rotation key - The key name for the rotation you want to use from PlayerData.

Changelog

  • 0.0.1: Initial Publish
  • 0.0.2: Added in-world instructions, swapped to OnPlayerRestored.