Position Sync
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:
- Join the world, move to a spot away from the Spawn point.
- 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:
- Open the Example Central Window from the window from the Unity Editor Menu under "VRChat SDK > 🏠 Example Central"
- Find this prefab in the list or search for it by title (same as the title of this page).
- 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.