Skip to content

Commit

Permalink
Limit roomscale movement per frame for a smoother experience
Browse files Browse the repository at this point in the history
  • Loading branch information
fholger committed Sep 2, 2023
1 parent bf2c3cf commit 052ad86
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2541,8 +2541,16 @@ void CPlayer::ProcessRoomscaleMovement(CXEntityProcessingCmd& ProcessingCmd)

Vec3 playerPos = m_pEntity->GetPos();
Vec3 offset = ProcessingCmd.GetHmdPos();
offset.z = 0;
Vec3 worldOffset = playerTransform * offset;
worldOffset.z = 0;
float length = worldOffset.len();
if (length > 0.02f)
{
// only do small movements per frame, as otherwise it can lead to stuttering responses from the engine
worldOffset *= 0.02f / length;
offset *= 0.02f / length;
}

// take terrain slope into account to move a bit up or down and prevent the engine from "jumping" the player vertically
if (m_pEntity->GetPhysics())
Expand Down

0 comments on commit 052ad86

Please sign in to comment.