로컬 회전
This commit is contained in:
parent
71c2b2b028
commit
1aebda717b
BIN
Content/Blueprints/Pawns/BP_PawnTank.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Pawns/BP_PawnTank.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Maps/Main.umap
(Stored with Git LFS)
BIN
Content/Maps/Main.umap
(Stored with Git LFS)
Binary file not shown.
@ -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);
|
||||
}
|
@ -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);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user