Skip to content
Snippets Groups Projects
Commit 612e8e2d authored by David Gilbert's avatar David Gilbert :bug:
Browse files

refactor(navigation): const correctness & brief code cleanup

parent 1df731ff
Branches
Tags
1 merge request!43refactor(movement): extracts turning logic from MovementCommponentBase to own Component
......@@ -124,20 +124,17 @@ void UTurnComponent::OnBeginSnapTurn(const FInputActionValue& Value)
}
void UTurnComponent::RotateCameraAndPawn(float Yaw)
void UTurnComponent::RotateCameraAndPawn(float Yaw) const
{
FVector NewLocation;
FRotator NewRotation;
FVector OrigLocation = VRPawn->GetActorLocation();
const FVector OrigLocation = VRPawn->GetActorLocation();
FVector PivotPoint = VRPawn->GetActorTransform().InverseTransformPosition(OrigLocation);
PivotPoint.Z = 0.0f;
FRotator OrigRotation = VRPawn->GetActorRotation();
const FRotator OrigRotation = VRPawn->GetActorRotation();
NewRotation = FRotator(0, VRPawn->GetActorRotation().Yaw + Yaw, 0);
const FRotator NewRotation = FRotator(0, VRPawn->GetActorRotation().Yaw + Yaw, 0);
NewLocation = OrigLocation + OrigRotation.RotateVector(PivotPoint);
const FVector NewLocation = OrigLocation + OrigRotation.RotateVector(PivotPoint);
VRPawn->Controller->SetControlRotation(NewRotation);
VRPawn->SetActorLocationAndRotation(NewLocation, NewRotation);
......
......@@ -74,6 +74,6 @@ private:
* 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) const;
bool bApplyDesktopRotation;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment