From 1aebda717b36b3e1beabedf59c6de5c7d9ad1cc7 Mon Sep 17 00:00:00 2001 From: 10000Je Date: Thu, 24 Apr 2025 19:24:42 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A1=9C=EC=BB=AC=20=ED=9A=8C=EC=A0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content/Blueprints/Pawns/BP_PawnTank.uasset | 4 ++-- Content/Maps/Main.umap | 4 ++-- Source/ToonTanks/Tank.cpp | 11 ++++++++++- Source/ToonTanks/Tank.h | 5 +++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Content/Blueprints/Pawns/BP_PawnTank.uasset b/Content/Blueprints/Pawns/BP_PawnTank.uasset index ad9872d..c3008bd 100644 --- a/Content/Blueprints/Pawns/BP_PawnTank.uasset +++ b/Content/Blueprints/Pawns/BP_PawnTank.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d38052c6e801403b435e83d096bd2e441b729954262dc82a5bf8da6d9a18db1a -size 37613 +oid sha256:b99506c7783c067bbc2a5e4b485ab34df92cb74f2f88d1f939b886b79dc64d03 +size 37849 diff --git a/Content/Maps/Main.umap b/Content/Maps/Main.umap index 690eaef..ef6b4e8 100644 --- a/Content/Maps/Main.umap +++ b/Content/Maps/Main.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:be4b434f627c8aff0bec1a02b63347d9f731a60b7096b25015d72bf9a9c6c25a -size 95150 +oid sha256:c8d703a05dee595a78ada04dcec3c8fdeb9c6907b9c3f6e53abd039979427872 +size 95209 diff --git a/Source/ToonTanks/Tank.cpp b/Source/ToonTanks/Tank.cpp index 7eb3018..f38e686 100644 --- a/Source/ToonTanks/Tank.cpp +++ b/Source/ToonTanks/Tank.cpp @@ -20,6 +20,7 @@ void ATank::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent); PlayerInputComponent->BindAxis(TEXT("MoveForward"), this, &ATank::Move); + PlayerInputComponent->BindAxis(TEXT("Turn"), this, &ATank::Turn); } void ATank::Move(float Value) @@ -27,5 +28,13 @@ void ATank::Move(float Value) FVector DeltaLocation = FVector::ZeroVector; float DeltaTime = UGameplayStatics::GetWorldDeltaSeconds(this); DeltaLocation.X = Value * DeltaTime * Speed; - this->AddActorLocalOffset(DeltaLocation); + this->AddActorLocalOffset(DeltaLocation, true); +} + +void ATank::Turn(float Value) +{ + FRotator DeltaRotation = FRotator::ZeroRotator; + float DeltaTime = UGameplayStatics::GetWorldDeltaSeconds(this); + DeltaRotation.Yaw = Value * DeltaTime * TurnRate; + this->AddActorLocalRotation(DeltaRotation, true); } \ No newline at end of file diff --git a/Source/ToonTanks/Tank.h b/Source/ToonTanks/Tank.h index 37d0409..454b7dd 100644 --- a/Source/ToonTanks/Tank.h +++ b/Source/ToonTanks/Tank.h @@ -30,5 +30,10 @@ private: UPROPERTY(EditAnywhere, Category = "Movement", BlueprintReadWrite, meta=(AllowPrivateAccess="true")) float Speed = 400.0f; + UPROPERTY(EditAnywhere, Category = "Movement") + float TurnRate = 45.0f; + void Move(float Value); + + void Turn(float Value); };