From 8333bc641b305aec024d2f971104eafa31ff7b68 Mon Sep 17 00:00:00 2001 From: winyunq Date: Sun, 21 Sep 2025 22:50:02 +0800 Subject: [PATCH 1/3] feat: Unify camera speed and implement zoom-based interpolation --- Content/AC_RTSCameraFollowMe.uasset | 3 --- Content/BP_RTSCamera.uasset | 4 +-- OpenRTSCamera.uplugin | 2 +- Source/OpenRTSCamera/Private/RTSCamera.cpp | 27 +++++++++++++------ .../OpenRTSCamera/Private/RTSSelectable.cpp | 2 +- Source/OpenRTSCamera/Public/OpenRTSCamera.h | 2 +- Source/OpenRTSCamera/Public/RTSCamera.h | 17 ++++++------ .../Public/RTSCameraBoundsVolume.h | 2 +- Source/OpenRTSCamera/Public/RTSHUD.h | 3 +-- Source/OpenRTSCamera/Public/RTSSelectable.h | 2 +- Source/OpenRTSCamera/Public/RTSSelector.h | 2 +- 11 files changed, 36 insertions(+), 30 deletions(-) delete mode 100644 Content/AC_RTSCameraFollowMe.uasset diff --git a/Content/AC_RTSCameraFollowMe.uasset b/Content/AC_RTSCameraFollowMe.uasset deleted file mode 100644 index cd63114..0000000 --- a/Content/AC_RTSCameraFollowMe.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1dceb093351e41cfe099ef87bdbfec3c42af2de2fd1fd821ea17d523df404a6b -size 25843 diff --git a/Content/BP_RTSCamera.uasset b/Content/BP_RTSCamera.uasset index 5682393..e90361f 100644 --- a/Content/BP_RTSCamera.uasset +++ b/Content/BP_RTSCamera.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ad0d80f14898ade77d58d545aeb3150e1acc8287d0322c24aa7442cd98dea54e -size 25195 +oid sha256:0d2e201517cc64e3e555b53bdec3f1705cb8590341e6f9d4c0f9b7448cd39a6c +size 27303 diff --git a/OpenRTSCamera.uplugin b/OpenRTSCamera.uplugin index 27e74e4..8aa1b38 100644 --- a/OpenRTSCamera.uplugin +++ b/OpenRTSCamera.uplugin @@ -6,7 +6,7 @@ "Description": "An Unreal Engine 5 open-source RTS/MOBA camera implementation that aims to be fully featured, customizable and dependable", "DocsURL": "https://github.com/HeyZoos/OpenRTSCamera/wiki", "EnabledByDefault": true, - "EngineVersion": "5.3.0", + "EngineVersion": "5.5.0", "FileVersion": 3, "FriendlyName": "OpenRTSCamera", "Installed": false, diff --git a/Source/OpenRTSCamera/Private/RTSCamera.cpp b/Source/OpenRTSCamera/Private/RTSCamera.cpp index e5606c8..fca62cb 100644 --- a/Source/OpenRTSCamera/Private/RTSCamera.cpp +++ b/Source/OpenRTSCamera/Private/RTSCamera.cpp @@ -17,7 +17,6 @@ URTSCamera::URTSCamera() this->CameraBlockingVolumeTag = FName("OpenRTSCamera#CameraBounds"); this->CollisionChannel = ECC_WorldStatic; this->DragExtent = 0.6f; - this->EdgeScrollSpeed = 50; this->DistanceFromEdgeThreshold = 0.1f; this->EnableCameraLag = true; this->EnableCameraRotationLag = true; @@ -26,7 +25,9 @@ URTSCamera::URTSCamera() this->FindGroundTraceLength = 100000; this->MaximumZoomLength = 5000; this->MinimumZoomLength = 500; - this->MoveSpeed = 50; + this->MaxMoveSpeed = 1024.0f; + this->MinMoveSpeed = 128.0f; + this->NowMoveSpeed = this->MinMoveSpeed; // Initialize NowMoveSpeed to MinMoveSpeed this->RotateSpeed = 45; this->StartingYAngle = -45.0f; this->StartingZAngle = 0; @@ -74,6 +75,8 @@ void URTSCamera::BeginPlay() this->CheckForEnhancedInputComponent(); this->BindInputMappingContext(); this->BindInputActions(); + + } } @@ -88,6 +91,9 @@ void URTSCamera::TickComponent( if (NetMode != NM_DedicatedServer && this->PlayerController->GetViewTarget() == this->Owner) { this->DeltaSeconds = DeltaTime; + + + this->ApplyMoveCameraCommands(); this->ConditionallyPerformEdgeScrolling(); this->ConditionallyKeepCameraAtDesiredZoomAboveGround(); @@ -96,7 +102,6 @@ void URTSCamera::TickComponent( this->ConditionallyApplyCameraBounds(); } } - void URTSCamera::FollowTarget(AActor* Target) { this->CameraFollowTarget = Target; @@ -114,6 +119,12 @@ void URTSCamera::OnZoomCamera(const FInputActionValue& Value) this->MinimumZoomLength, this->MaximumZoomLength ); + + // Calculate Alpha for Lerp (0 at min zoom, 1 at max zoom) + float Alpha = (this->DesiredZoomLength - this->MinimumZoomLength) / (this->MaximumZoomLength - this->MinimumZoomLength); + + // Lerp NowMoveSpeed between MinMoveSpeed and MaxMoveSpeed + this->NowMoveSpeed = FMath::Lerp(this->MinMoveSpeed, this->MaxMoveSpeed, Alpha); } void URTSCamera::OnRotateCamera(const FInputActionValue& Value) @@ -228,7 +239,7 @@ void URTSCamera::ApplyMoveCameraCommands() { auto Movement = FVector2D(X, Y); Movement.Normalize(); - Movement *= this->MoveSpeed * Scale * this->DeltaSeconds; + Movement *= this->NowMoveSpeed * Scale * this->DeltaSeconds; this->Root->SetWorldLocation( this->Root->GetComponentLocation() + FVector(Movement.X, Movement.Y, 0.0f) ); @@ -424,7 +435,7 @@ void URTSCamera::EdgeScrollLeft() const const auto Movement = UKismetMathLibrary::FClamp(NormalizedMousePosition, 0.0, 1.0); this->Root->AddRelativeLocation( - -1 * this->Root->GetRightVector() * Movement * this->EdgeScrollSpeed * this->DeltaSeconds + -1 * this->Root->GetRightVector() * Movement * this->NowMoveSpeed * this->DeltaSeconds ); } @@ -440,7 +451,7 @@ void URTSCamera::EdgeScrollRight() const const auto Movement = UKismetMathLibrary::FClamp(NormalizedMousePosition, 0.0, 1.0); this->Root->AddRelativeLocation( - this->Root->GetRightVector() * Movement * this->EdgeScrollSpeed * this->DeltaSeconds + this->Root->GetRightVector() * Movement * this->NowMoveSpeed * this->DeltaSeconds ); } @@ -456,7 +467,7 @@ void URTSCamera::EdgeScrollUp() const const auto Movement = 1 - UKismetMathLibrary::FClamp(NormalizedMousePosition, 0.0, 1.0); this->Root->AddRelativeLocation( - this->Root->GetForwardVector() * Movement * this->EdgeScrollSpeed * this->DeltaSeconds + this->Root->GetForwardVector() * Movement * this->NowMoveSpeed * this->DeltaSeconds ); } @@ -472,7 +483,7 @@ void URTSCamera::EdgeScrollDown() const const auto Movement = UKismetMathLibrary::FClamp(NormalizedMousePosition, 0.0, 1.0); this->Root->AddRelativeLocation( - -1 * this->Root->GetForwardVector() * Movement * this->EdgeScrollSpeed * this->DeltaSeconds + -1 * this->Root->GetForwardVector() * Movement * this->NowMoveSpeed * this->DeltaSeconds ); } diff --git a/Source/OpenRTSCamera/Private/RTSSelectable.cpp b/Source/OpenRTSCamera/Private/RTSSelectable.cpp index 56c0479..01304ae 100644 --- a/Source/OpenRTSCamera/Private/RTSSelectable.cpp +++ b/Source/OpenRTSCamera/Private/RTSSelectable.cpp @@ -1 +1 @@ -#include "RTSSelectable.h" +#include "RTSSelectable.h" diff --git a/Source/OpenRTSCamera/Public/OpenRTSCamera.h b/Source/OpenRTSCamera/Public/OpenRTSCamera.h index 9e39ca2..0e6163d 100644 --- a/Source/OpenRTSCamera/Public/OpenRTSCamera.h +++ b/Source/OpenRTSCamera/Public/OpenRTSCamera.h @@ -2,7 +2,7 @@ #pragma once -#include "CoreMinimal.h" +#include #include "Modules/ModuleManager.h" class FOpenRTSCameraModule : public IModuleInterface diff --git a/Source/OpenRTSCamera/Public/RTSCamera.h b/Source/OpenRTSCamera/Public/RTSCamera.h index bb579d2..25eca16 100644 --- a/Source/OpenRTSCamera/Public/RTSCamera.h +++ b/Source/OpenRTSCamera/Public/RTSCamera.h @@ -2,7 +2,7 @@ #pragma once -#include "CoreMinimal.h" +#include #include "InputMappingContext.h" #include "Camera/CameraComponent.h" #include "Components/ActorComponent.h" @@ -66,7 +66,9 @@ class OPENRTSCAMERA_API URTSCamera : public UActorComponent float StartingZAngle; UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RTSCamera") - float MoveSpeed; + float MaxMoveSpeed; + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RTSCamera") + float MinMoveSpeed; UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RTSCamera") float RotateSpeed; @@ -104,13 +106,8 @@ class OPENRTSCAMERA_API URTSCamera : public UActorComponent UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RTSCamera - Edge Scroll Settings") bool EnableEdgeScrolling; - UPROPERTY( - BlueprintReadWrite, - EditAnywhere, - Category = "RTSCamera - Edge Scroll Settings", - meta=(EditCondition="EnableEdgeScrolling") - ) - float EdgeScrollSpeed; + + UPROPERTY( BlueprintReadWrite, EditAnywhere, @@ -199,4 +196,6 @@ class OPENRTSCAMERA_API URTSCamera : public UActorComponent FVector2D DragStartLocation; UPROPERTY() TArray MoveCameraCommands; + UPROPERTY() + float NowMoveSpeed; }; diff --git a/Source/OpenRTSCamera/Public/RTSCameraBoundsVolume.h b/Source/OpenRTSCamera/Public/RTSCameraBoundsVolume.h index 55a3a0d..33ce6ad 100644 --- a/Source/OpenRTSCamera/Public/RTSCameraBoundsVolume.h +++ b/Source/OpenRTSCamera/Public/RTSCameraBoundsVolume.h @@ -2,7 +2,7 @@ #pragma once -#include "CoreMinimal.h" +#include #include "GameFramework/CameraBlockingVolume.h" #include "RTSCameraBoundsVolume.generated.h" diff --git a/Source/OpenRTSCamera/Public/RTSHUD.h b/Source/OpenRTSCamera/Public/RTSHUD.h index 694685c..e4215a8 100644 --- a/Source/OpenRTSCamera/Public/RTSHUD.h +++ b/Source/OpenRTSCamera/Public/RTSHUD.h @@ -2,7 +2,7 @@ #pragma once -#include "CoreMinimal.h" +#include #include "GameFramework/HUD.h" #include "RTSHUD.generated.h" @@ -13,7 +13,6 @@ class OPENRTSCAMERA_API ARTSHUD : public AHUD public: ARTSHUD(); - UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Selection Box") FLinearColor SelectionBoxColor; diff --git a/Source/OpenRTSCamera/Public/RTSSelectable.h b/Source/OpenRTSCamera/Public/RTSSelectable.h index 412c59e..dc7420b 100644 --- a/Source/OpenRTSCamera/Public/RTSSelectable.h +++ b/Source/OpenRTSCamera/Public/RTSSelectable.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "RTSSelectable.generated.h" UCLASS(Blueprintable, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) diff --git a/Source/OpenRTSCamera/Public/RTSSelector.h b/Source/OpenRTSCamera/Public/RTSSelector.h index 4d164b5..da7a1b7 100644 --- a/Source/OpenRTSCamera/Public/RTSSelector.h +++ b/Source/OpenRTSCamera/Public/RTSSelector.h @@ -2,7 +2,7 @@ #pragma once -#include "CoreMinimal.h" +#include #include "InputAction.h" #include "InputMappingContext.h" #include "RTSHUD.h" From c13250fbec5867f9379136225bce2ab203cc7c9e Mon Sep 17 00:00:00 2001 From: winyunq Date: Sat, 27 Sep 2025 15:52:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E9=95=9C=E5=A4=B4=E4=BD=8D=E7=BD=AE=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E9=9D=A0=E8=B0=B1=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/OpenRTSCamera/Private/RTSCamera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/OpenRTSCamera/Private/RTSCamera.cpp b/Source/OpenRTSCamera/Private/RTSCamera.cpp index fca62cb..e391fd5 100644 --- a/Source/OpenRTSCamera/Private/RTSCamera.cpp +++ b/Source/OpenRTSCamera/Private/RTSCamera.cpp @@ -259,7 +259,7 @@ void URTSCamera::CollectComponentDependencyReferences() void URTSCamera::ConfigureSpringArm() { - this->DesiredZoomLength = this->MaximumZoomLength; + this->DesiredZoomLength = this->MinimumZoomLength; this->SpringArm->TargetArmLength = this->DesiredZoomLength; this->SpringArm->bDoCollisionTest = false; this->SpringArm->bEnableCameraLag = this->EnableCameraLag; From 0f03a11e9a6bb771aebca5798cd969d685b1c461 Mon Sep 17 00:00:00 2001 From: winyunq Date: Thu, 23 Oct 2025 15:31:36 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E9=99=90=E5=88=B6=EF=BC=8C=E5=87=86=E5=A4=87=E9=92=88=E5=AF=B9?= =?UTF-8?q?5.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenRTSCamera.uplugin | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenRTSCamera.uplugin b/OpenRTSCamera.uplugin index 8aa1b38..4793bc1 100644 --- a/OpenRTSCamera.uplugin +++ b/OpenRTSCamera.uplugin @@ -6,7 +6,6 @@ "Description": "An Unreal Engine 5 open-source RTS/MOBA camera implementation that aims to be fully featured, customizable and dependable", "DocsURL": "https://github.com/HeyZoos/OpenRTSCamera/wiki", "EnabledByDefault": true, - "EngineVersion": "5.5.0", "FileVersion": 3, "FriendlyName": "OpenRTSCamera", "Installed": false,