From af31b84ba766d7ca2a96ce2d53158c697b538200 Mon Sep 17 00:00:00 2001 From: meishibiezb <750783119@qq.com> Date: Mon, 16 Mar 2026 01:16:33 +0800 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E8=93=9D=E5=9B=BE=E7=9A=84=E9=AA=A8=E9=AA=BC=E7=BD=91?= =?UTF-8?q?=E6=A0=BC=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content/Blueprints/BP_TestChar.uasset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content/Blueprints/BP_TestChar.uasset b/Content/Blueprints/BP_TestChar.uasset index 81a91fb..49c0cc4 100644 --- a/Content/Blueprints/BP_TestChar.uasset +++ b/Content/Blueprints/BP_TestChar.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:06d7c7e081e57763f56373431a406553c46083c7b778f58fb71f6fbd9dc86ce6 -size 36123 +oid sha256:c4637904c42b530ae49ec7240c7601e8da14b164c4a93275608961149f8a7577 +size 36455 From 563de492f39311e993fc2d6cb972f46117ae1904 Mon Sep 17 00:00:00 2001 From: meishibiezb <750783119@qq.com> Date: Mon, 16 Mar 2026 23:02:20 +0800 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20=E5=8A=A8=E7=94=BB=E8=93=9D?= =?UTF-8?q?=E5=9B=BE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content/Blueprints/Anim/ABP_TestChar.uasset | 3 +++ Content/Blueprints/Anim/BS_Walk_Run.uasset | 3 +++ Content/Blueprints/BP_TestChar.uasset | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 Content/Blueprints/Anim/ABP_TestChar.uasset create mode 100644 Content/Blueprints/Anim/BS_Walk_Run.uasset diff --git a/Content/Blueprints/Anim/ABP_TestChar.uasset b/Content/Blueprints/Anim/ABP_TestChar.uasset new file mode 100644 index 0000000..eb7e108 --- /dev/null +++ b/Content/Blueprints/Anim/ABP_TestChar.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b4b2bab6d1a6f2a33c704dab74031555c6df1e07d058ef3f0e2a0dfbd99da70 +size 102091 diff --git a/Content/Blueprints/Anim/BS_Walk_Run.uasset b/Content/Blueprints/Anim/BS_Walk_Run.uasset new file mode 100644 index 0000000..da04a4b --- /dev/null +++ b/Content/Blueprints/Anim/BS_Walk_Run.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a2c8ffa6ca17ed3dfa00e59c7720de2f1c530d0916ef4a5833fdd58587bc04d +size 8162 diff --git a/Content/Blueprints/BP_TestChar.uasset b/Content/Blueprints/BP_TestChar.uasset index 49c0cc4..3927f27 100644 --- a/Content/Blueprints/BP_TestChar.uasset +++ b/Content/Blueprints/BP_TestChar.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c4637904c42b530ae49ec7240c7601e8da14b164c4a93275608961149f8a7577 -size 36455 +oid sha256:8dfb700584fc781c6b9db0e75a7678d9cc46b3112318b59560e2fbd72f32dc2f +size 36237 From bdf3a1a8daba8f3cecd9462cbcf5faabe199a021 Mon Sep 17 00:00:00 2001 From: meishibiezb <750783119@qq.com> Date: Mon, 16 Mar 2026 23:39:12 +0800 Subject: [PATCH 3/7] =?UTF-8?q?feat:=20=E6=9B=B4=E6=94=B9=E5=8A=A8?= =?UTF-8?q?=E7=94=BB=E8=93=9D=E5=9B=BE=E5=92=8C=E6=B7=B7=E5=90=88=E7=A9=BA?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content/Blueprints/Anim/BS_Walk_Run.uasset | 4 ++-- Content/Blueprints/BP_TestChar.uasset | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Content/Blueprints/Anim/BS_Walk_Run.uasset b/Content/Blueprints/Anim/BS_Walk_Run.uasset index da04a4b..f06a859 100644 --- a/Content/Blueprints/Anim/BS_Walk_Run.uasset +++ b/Content/Blueprints/Anim/BS_Walk_Run.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0a2c8ffa6ca17ed3dfa00e59c7720de2f1c530d0916ef4a5833fdd58587bc04d -size 8162 +oid sha256:5c9eed871df22234939af46e6e1512f1971bd97fea1dc9ed8f07cd51fd670216 +size 9226 diff --git a/Content/Blueprints/BP_TestChar.uasset b/Content/Blueprints/BP_TestChar.uasset index 3927f27..b7ad136 100644 --- a/Content/Blueprints/BP_TestChar.uasset +++ b/Content/Blueprints/BP_TestChar.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8dfb700584fc781c6b9db0e75a7678d9cc46b3112318b59560e2fbd72f32dc2f -size 36237 +oid sha256:dfe5cd1402fd915a4ea9ec7909b8ae450363b316810ac0492aa80d959eaecc9d +size 35747 From b8e1b5814f82d113234d63aefce16a41f506a114 Mon Sep 17 00:00:00 2001 From: meishibiezb <750783119@qq.com> Date: Tue, 17 Mar 2026 11:33:45 +0800 Subject: [PATCH 4/7] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E7=A7=BB=E5=8A=A8=E6=97=B6=E6=97=8B=E8=BD=AC=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content/Blueprints/BP_TestChar.uasset | 4 ++-- Source/lonese/CameraPawn.cpp | 2 +- Source/lonese/MyCharacter.cpp | 18 ++++++++++++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Content/Blueprints/BP_TestChar.uasset b/Content/Blueprints/BP_TestChar.uasset index b7ad136..14468e4 100644 --- a/Content/Blueprints/BP_TestChar.uasset +++ b/Content/Blueprints/BP_TestChar.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dfe5cd1402fd915a4ea9ec7909b8ae450363b316810ac0492aa80d959eaecc9d -size 35747 +oid sha256:b755ef082e56584d4bda7dab2afff377e0cca07e9842c9030d55add56af91d24 +size 36046 diff --git a/Source/lonese/CameraPawn.cpp b/Source/lonese/CameraPawn.cpp index acdeaf8..6eb2e28 100644 --- a/Source/lonese/CameraPawn.cpp +++ b/Source/lonese/CameraPawn.cpp @@ -74,7 +74,7 @@ void ACameraPawn::BeginPlay() // 附加到父物体 this->AttachToActor(FollowTarget, FAttachmentTransformRules::KeepWorldTransform); - + this->GetRootComponent()->SetAbsolute(false, true, true); } // 设置自身旋转 diff --git a/Source/lonese/MyCharacter.cpp b/Source/lonese/MyCharacter.cpp index 4296992..2c27764 100644 --- a/Source/lonese/MyCharacter.cpp +++ b/Source/lonese/MyCharacter.cpp @@ -12,10 +12,19 @@ void AMyCharacter::Move(const FInputActionValue& Value) { auto f2d = Value.Get(); - auto f = GetActorForwardVector(); - auto r = GetActorRightVector(); + + // 移动 + auto f = FRotator(0, GetControlRotation().Yaw, 0).Vector(); + auto r = -f.Cross(FVector::UpVector); AddMovementInput(f * f2d.X); AddMovementInput(r * f2d.Y); + + // 转向 + if (f2d.SizeSquared() > 0.01f) + { + FRotator Rot = FRotator(0, FMath::Atan2(f2d.Y, f2d.X) * 180.0f / PI, 0); + SetActorRotation(Rot); + } } void AMyCharacter::BeginRun(const FInputActionValue& Value) @@ -84,6 +93,11 @@ AMyCharacter::AMyCharacter() PrimaryActorTick.bCanEverTick = true; GetCharacterMovement()->GetNavAgentPropertiesRef().bCanCrouch = true; + + // 禁用控制器旋转 + bUseControllerRotationPitch = false; + bUseControllerRotationYaw = false; + bUseControllerRotationRoll = false; } // Called when the game starts or when spawned From 3b3873e889ebb729f0423501d1db2a4ee5d0e1f6 Mon Sep 17 00:00:00 2001 From: meishibiezb <750783119@qq.com> Date: Tue, 17 Mar 2026 11:40:22 +0800 Subject: [PATCH 5/7] =?UTF-8?q?feat:=20=E5=8A=A0=E5=85=A5=E4=BA=86?= =?UTF-8?q?=E5=8A=A8=E7=94=BB=E6=8F=92=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/lonese/MyCharacter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/lonese/MyCharacter.cpp b/Source/lonese/MyCharacter.cpp index 2c27764..e12900d 100644 --- a/Source/lonese/MyCharacter.cpp +++ b/Source/lonese/MyCharacter.cpp @@ -22,8 +22,10 @@ void AMyCharacter::Move(const FInputActionValue& Value) // 转向 if (f2d.SizeSquared() > 0.01f) { - FRotator Rot = FRotator(0, FMath::Atan2(f2d.Y, f2d.X) * 180.0f / PI, 0); - SetActorRotation(Rot); + FRotator Rot = FVector(f2d.X, f2d.Y, 0).Rotation() + FRotator(0, GetControlRotation().Yaw, 0); + float InterpSpeed = 10.0f; + FRotator NewRotation = FMath::RInterpTo(GetActorRotation(), Rot, GetWorld()->GetDeltaSeconds(), InterpSpeed); + SetActorRotation(NewRotation); } } From 0592cb2c045fb00ca4362e0941e39ea90ac25b8c Mon Sep 17 00:00:00 2001 From: meishibiezb <750783119@qq.com> Date: Tue, 17 Mar 2026 11:48:12 +0800 Subject: [PATCH 6/7] =?UTF-8?q?feat:=20=E6=97=8B=E8=BD=AC=E9=95=9C?= =?UTF-8?q?=E5=A4=B4=E5=90=8C=E6=97=B6=E6=97=8B=E8=BD=AC=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/lonese/CameraPawn.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/lonese/CameraPawn.cpp b/Source/lonese/CameraPawn.cpp index 6eb2e28..973d3ad 100644 --- a/Source/lonese/CameraPawn.cpp +++ b/Source/lonese/CameraPawn.cpp @@ -17,8 +17,15 @@ void ACameraPawn::CameraZoom(const FInputActionValue& Value) void ACameraPawn::CameraRotate(const FInputActionValue& Value) { auto f = Value.Get(); - FRotator r = FRotator(0.0f, f * RotateSpeed, 0.0f); + FRotator r = FRotator(0.0f, -f * RotateSpeed, 0.0f); AddActorWorldRotation(r); + + // 同时旋转控制器 + auto c = Cast(FollowTarget->GetController()); + if (c) + { + c->SetControlRotation(GetActorRotation()); + } } void ACameraPawn::CameraMove(const FInputActionValue& Value) From e57ac424ff8136b48167d9c0fbe59dac4e1008ac Mon Sep 17 00:00:00 2001 From: meishibiezb <750783119@qq.com> Date: Tue, 17 Mar 2026 11:54:41 +0800 Subject: [PATCH 7/7] =?UTF-8?q?fixed:=20=E9=87=8D=E7=BD=AE=E6=91=84?= =?UTF-8?q?=E5=83=8F=E5=A4=B4=E6=97=8B=E8=BD=AC=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E4=B9=9F=E9=87=8D=E7=BD=AE=E6=8E=A7=E5=88=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/lonese/CameraPawn.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/lonese/CameraPawn.cpp b/Source/lonese/CameraPawn.cpp index 973d3ad..80575c7 100644 --- a/Source/lonese/CameraPawn.cpp +++ b/Source/lonese/CameraPawn.cpp @@ -45,6 +45,13 @@ void ACameraPawn::CameraReset(const FInputActionValue& Value) SpringArmComponent->TargetArmLength = InitialArmLength; SetActorRotation(InitialRotation); SetActorRelativeLocation(FVector::ZeroVector); + + // 同时旋转控制器 + auto c = Cast(FollowTarget->GetController()); + if (c) + { + c->SetControlRotation(GetActorRotation()); + } } // Sets default values