Skip to content
Snippets Groups Projects
Commit cb8c70fb authored by Daniel Rupp's avatar Daniel Rupp
Browse files

fix(movement): fixed desktop mode pitch by only using RotateCameraAndPawn() when in VR

parent 4664f879
No related branches found
No related tags found
1 merge request!43refactor(movement): extracts turning logic from MovementCommponentBase to own Component
...@@ -86,17 +86,23 @@ void UTurnComponent::OnBeginTurn(const FInputActionValue& Value) ...@@ -86,17 +86,23 @@ void UTurnComponent::OnBeginTurn(const FInputActionValue& Value)
const FVector2D TurnValue = Value.Get<FVector2D>(); const FVector2D TurnValue = Value.Get<FVector2D>();
if (TurnValue.X != 0.f) if (TurnValue.X != 0.f)
{
if (UVirtualRealityUtilities::IsDesktopMode() && bApplyDesktopRotation)
{
VRPawn->AddControllerYawInput(TurnRateFactor * TurnValue.X);
} else
{ {
RotateCameraAndPawn(TurnRateFactor * TurnValue.X); RotateCameraAndPawn(TurnRateFactor * TurnValue.X);
} }
}
/*if (TurnValue.Y != 0.f) if (TurnValue.Y != 0.f)
{ {
if (UVirtualRealityUtilities::IsDesktopMode() && bApplyDesktopRotation) if (UVirtualRealityUtilities::IsDesktopMode() && bApplyDesktopRotation)
{ {
VRPawn->AddControllerPitchInput(TurnRateFactor * -TurnValue.Y); VRPawn->AddControllerPitchInput(TurnRateFactor * -TurnValue.Y);
} }
}*/ }
} }
void UTurnComponent::OnBeginSnapTurn(const FInputActionValue& Value) void UTurnComponent::OnBeginSnapTurn(const FInputActionValue& Value)
...@@ -115,6 +121,7 @@ void UTurnComponent::OnBeginSnapTurn(const FInputActionValue& Value) ...@@ -115,6 +121,7 @@ void UTurnComponent::OnBeginSnapTurn(const FInputActionValue& Value)
} }
} }
void UTurnComponent::RotateCameraAndPawn(float Yaw) void UTurnComponent::RotateCameraAndPawn(float Yaw)
{ {
FVector NewLocation; FVector NewLocation;
......
...@@ -70,6 +70,10 @@ private: ...@@ -70,6 +70,10 @@ private:
UPROPERTY() UPROPERTY()
class UInputMappingContext* IMCTurn; class UInputMappingContext* IMCTurn;
/**
* If we just use VRPawn->AddControllerYawInput(Yaw), rotation is around tracking origin instead of the actual player position
* This function updates the pawns rotation and location to result in a rotation around the users tracked position.
*/
void RotateCameraAndPawn(float Yaw); void RotateCameraAndPawn(float Yaw);
bool bApplyDesktopRotation; bool bApplyDesktopRotation;
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment