From b3bbca282daf56f1f9b25fa8520639ac946fdf47 Mon Sep 17 00:00:00 2001 From: aicorr Date: Sun, 16 Feb 2025 17:36:16 +0530 Subject: [PATCH] First complete implementation of 3d movement --- Content/Blueprints/BP_SpaceshipPawn.uasset | 4 ++-- Content/Input/IA_MouseLook.uasset | 2 +- Content/Input/IMC_Spaceship.uasset | 4 ++-- Source/MyProject3/SpaceshipPawn.cpp | 8 +++++--- Source/MyProject3/SpaceshipPawn.h | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Content/Blueprints/BP_SpaceshipPawn.uasset b/Content/Blueprints/BP_SpaceshipPawn.uasset index 3bbcb3b..20beccd 100644 --- a/Content/Blueprints/BP_SpaceshipPawn.uasset +++ b/Content/Blueprints/BP_SpaceshipPawn.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:354c71aaba719e174ba9461bba1c2198e54cf76cb44d855b38236971de12fe45 -size 33170 +oid sha256:0b826e4d68561eec671694360d02d1c93a17d710ebf66d42374608ffb9c56712 +size 33223 diff --git a/Content/Input/IA_MouseLook.uasset b/Content/Input/IA_MouseLook.uasset index e355ac0..2fca489 100644 --- a/Content/Input/IA_MouseLook.uasset +++ b/Content/Input/IA_MouseLook.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bfc00aea89da848e56155754194a2bc52f0bff9825666aeb8b1dd1ccec6ec348 +oid sha256:e3aec2555a024e3687bc73a1d721404e15f22ffc54f3a8fc5f3ea484f59a80fc size 2075 diff --git a/Content/Input/IMC_Spaceship.uasset b/Content/Input/IMC_Spaceship.uasset index 9dfdaf5..56e5e94 100644 --- a/Content/Input/IMC_Spaceship.uasset +++ b/Content/Input/IMC_Spaceship.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eb9fb49c50ae73afd719ed9f795e34340fa89d6671e2963d0a25b93f31589461 -size 6259 +oid sha256:7fd69807528795d2fce8f5aa3033cc8a407fe8754d768ecd1a6cd850f87bf88d +size 5519 diff --git a/Source/MyProject3/SpaceshipPawn.cpp b/Source/MyProject3/SpaceshipPawn.cpp index ac983ba..1117057 100644 --- a/Source/MyProject3/SpaceshipPawn.cpp +++ b/Source/MyProject3/SpaceshipPawn.cpp @@ -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); diff --git a/Source/MyProject3/SpaceshipPawn.h b/Source/MyProject3/SpaceshipPawn.h index 1fefc60..d4d3bf3 100644 --- a/Source/MyProject3/SpaceshipPawn.h +++ b/Source/MyProject3/SpaceshipPawn.h @@ -36,7 +36,7 @@ protected: class UInputAction* ThrottleAction; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input") - class UInputAction* MouseControlAction; + class UInputAction* MouseLookAction; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input") class UInputAction* FireAction;