First complete implementation of 3d movement
This commit is contained in:
@@ -24,9 +24,10 @@ ASpaceshipPawn::ASpaceshipPawn()
|
||||
CameraSpringArm->SetupAttachment(RootComponent);
|
||||
CameraSpringArm->TargetArmLength = 400.0f;
|
||||
CameraSpringArm->bEnableCameraLag = true;
|
||||
CameraSpringArm->CameraLagSpeed = 3.0f;
|
||||
CameraSpringArm->CameraLagSpeed = 10.0f;
|
||||
CameraSpringArm->bEnableCameraRotationLag = true;
|
||||
CameraSpringArm->CameraRotationLagSpeed = 10.0f;
|
||||
CameraSpringArm->CameraLagMaxDistance = 7.0f;
|
||||
CameraSpringArm->bUsePawnControlRotation = false; // Add this line
|
||||
CameraSpringArm->bInheritPitch = true; // Add this line
|
||||
CameraSpringArm->bInheritYaw = true; // Add this line
|
||||
@@ -44,6 +45,7 @@ ASpaceshipPawn::ASpaceshipPawn()
|
||||
CurrentPitch = 0.0f;
|
||||
CurrentYaw = 0.0f;
|
||||
TargetRotation = FRotator::ZeroRotator;
|
||||
LastMouseDelta = FVector2D::ZeroVector;
|
||||
}
|
||||
|
||||
void ASpaceshipPawn::BeginPlay()
|
||||
@@ -124,7 +126,7 @@ void ASpaceshipPawn::Tick(float DeltaTime)
|
||||
// Update rotation based on smoothed mouse movement
|
||||
CurrentYaw += MouseDeltaSmoothed.X * MouseSensitivity * DeltaTime * 60.0f; // Multiply by 60 to normalize for frame rate
|
||||
CurrentPitch = FMath::ClampAngle(
|
||||
CurrentPitch + (-MouseDeltaSmoothed.Y * MouseSensitivity * DeltaTime * 60.0f),
|
||||
CurrentPitch + (MouseDeltaSmoothed.Y * MouseSensitivity * DeltaTime * 60.0f),
|
||||
-85.0f,
|
||||
85.0f
|
||||
);
|
||||
@@ -176,7 +178,7 @@ void ASpaceshipPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputCompo
|
||||
EnhancedInputComponent->BindAction(ThrottleAction, ETriggerEvent::Completed, this, &ASpaceshipPawn::HandleThrottleReleased);
|
||||
|
||||
// Bind mouse control
|
||||
EnhancedInputComponent->BindAction(MouseControlAction, ETriggerEvent::Triggered, this, &ASpaceshipPawn::HandleMouseLook);
|
||||
EnhancedInputComponent->BindAction(MouseLookAction, ETriggerEvent::Triggered, this, &ASpaceshipPawn::HandleMouseLook);
|
||||
|
||||
// Bind fire action
|
||||
EnhancedInputComponent->BindAction(FireAction, ETriggerEvent::Triggered, this, &ASpaceshipPawn::HandleFire);
|
||||
|
||||
Reference in New Issue
Block a user