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