From 052ad86d46474a273f1ac1ab928f8fd89a62c5aa Mon Sep 17 00:00:00 2001 From: Holger Frydrych Date: Sat, 2 Sep 2023 23:25:57 +0200 Subject: [PATCH] Limit roomscale movement per frame for a smoother experience --- Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp b/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp index 82a9183..61f7361 100644 --- a/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp +++ b/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp @@ -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())