From 9ea93a8b7c92ef8cb0e7c40ab2f3cf5399af3156 Mon Sep 17 00:00:00 2001
From: Christian Helwig <helwig@vr.rwth-aachen.de>
Date: Thu, 12 Sep 2024 12:44:40 +0200
Subject: [PATCH] fix(movement): Fixes a bug where the movement velocity is
 dependent on the controller rotation

---
 .../Private/Pawn/Navigation/CollisionHandlingMovement.cpp  | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp b/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp
index 4f86fc4f..d75c4d40 100644
--- a/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp
+++ b/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp
@@ -41,8 +41,11 @@ void UCollisionHandlingMovement::TickComponent(float DeltaTime, enum ELevelTick
 	{
 		// you are only allowed to move horizontally in NAV_WALK
 		// everything else will be handled by stepping-up/gravity
-		// so remove Z component for the input vector of the UFloatingPawnMovement
-		InputVector.Z = 0.0f;
+		// so rotate the input vector onto horizontal plane
+		const FRotator InputRot = FRotator(InputVector.Rotation());
+		const FRotator InputYaw = FRotator(0, InputRot.Yaw, 0);
+		InputVector = InputRot.UnrotateVector(InputVector);
+		InputVector = InputYaw.RotateVector(InputVector);
 		ConsumeInputVector();
 		AddInputVector(InputVector);
 	}
-- 
GitLab