Smooth MoveTo Player

This commit is contained in:
baz 2024-07-15 23:41:24 +01:00
parent 7f693b9155
commit addeb47c04
7 changed files with 24 additions and 8 deletions

BIN
Content/Enemy/BP_AIController.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/Enemy/BP_EnemyCharacter.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/Enemy/BT_Enemy.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/Levels/Level.umap (Stored with Git LFS)

Binary file not shown.

BIN
Content/TestGoldPickup.uasset (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -17,6 +17,7 @@ AVampireAIController::AVampireAIController(const FObjectInitializer& object_init
void AVampireAIController::BeginPlay()
{
Super::BeginPlay();
GetWorldTimerManager().SetTimer(PawnMoveToTimerHandle, this, &AVampireAIController::PawnMoveTo, 0.25f, true);
}
void AVampireAIController::Tick(float DeltaTime)
@ -69,6 +70,12 @@ void AVampireAIController::OnDeath(FDamageInfo info)
characterMovementComponent->StopActiveMovement();
characterMovementComponent->SetComponentTickEnabled(false);
}
GetWorldTimerManager().ClearTimer(PawnMoveToTimerHandle);
EnemyCharacter->SetLifeSpan(0.1f);
}
void AVampireAIController::PawnMoveTo()
{
MoveToActor(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0), 5);
}

View File

@ -27,6 +27,8 @@ private:
AEnemyCharacter* EnemyCharacter;
FTimerHandle PawnMoveToTimerHandle;
public:
AVampireAIController(const FObjectInitializer& object_initializer);
@ -45,4 +47,8 @@ public:
UFUNCTION()
virtual void OnDeath(FDamageInfo info);
private:
UFUNCTION()
virtual void PawnMoveTo();
};