Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Attempt to reduce remote VR player position lag #631

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions ValheimVRMod/Scripts/VRPlayerSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private void writeData(ZPackage pkg, GameObject obj, Vector3 ownerVelocity)
rotation *= DUNDR_SINGLE_HAND_ADDITIONAL_ROTATION;
}
}
pkg.Write(obj.transform.position);
pkg.Write(obj.transform.position - player.transform.position);
pkg.Write(rotation);
pkg.Write(ownerVelocity);
}
Expand Down Expand Up @@ -271,12 +271,15 @@ private void maybePullBow(bool pulling) {
private void extractAndUpdate(ZPackage pkg, ref GameObject obj, ref Vector3 tempRelPos, bool hasTempRelPos)
{
// Extract package data
var position = pkg.ReadVector3();
var position = pkg.ReadVector3() + player.transform.position;
var rotation = pkg.ReadQuaternion();
var velocity = pkg.ReadVector3();

// Update position based on last written position, velocity, and elapsed time since last data revision
position += velocity * deltaTimeCounter;

if (!player.m_attached)
{
// Update position based on last written position, velocity, and elapsed time since last data revision
position += velocity * deltaTimeCounter;
}

if (!hasTempRelPos)
{
Expand Down