로컬 회전

This commit is contained in:
강민제 2025-04-24 19:24:42 +09:00
parent 71c2b2b028
commit 1aebda717b
4 changed files with 19 additions and 5 deletions

Binary file not shown.

BIN
Content/Maps/Main.umap (Stored with Git LFS)

Binary file not shown.

View File

@ -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);
}

View File

@ -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);
};