From addeb47c042ac06e88e250f04d027432bf6fe2e9 Mon Sep 17 00:00:00 2001 From: baz Date: Mon, 15 Jul 2024 23:41:24 +0100 Subject: [PATCH] Smooth MoveTo Player --- Content/Enemy/BP_AIController.uasset | 4 ++-- Content/Enemy/BP_EnemyCharacter.uasset | 4 ++-- Content/Enemy/BT_Enemy.uasset | 4 ++-- Content/Levels/Level.umap | 4 ++-- Content/TestGoldPickup.uasset | 3 +++ Source/vampires/VampireAIController.cpp | 7 +++++++ Source/vampires/VampireAIController.h | 6 ++++++ 7 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 Content/TestGoldPickup.uasset diff --git a/Content/Enemy/BP_AIController.uasset b/Content/Enemy/BP_AIController.uasset index 68faa1c..8b4a0b6 100644 --- a/Content/Enemy/BP_AIController.uasset +++ b/Content/Enemy/BP_AIController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5b0213943a565b240a8f05ff4c62befcf55e45b49545d650c5b085abe251af6a -size 20008 +oid sha256:7240119efa81695648e4d7e39a0a66382ef69ad97845c6c55754b118b229142e +size 14422 diff --git a/Content/Enemy/BP_EnemyCharacter.uasset b/Content/Enemy/BP_EnemyCharacter.uasset index ba23900..cf9afc4 100644 --- a/Content/Enemy/BP_EnemyCharacter.uasset +++ b/Content/Enemy/BP_EnemyCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:024e1b20f2091a246c7b1a55530b3c2bc9f9fb0307878852dad224d28f6c007a -size 31368 +oid sha256:72cdbc9edd071070d4c21ddb8e7bae8b5b5d51cd89cfcc30f6f82504d23f6637 +size 29261 diff --git a/Content/Enemy/BT_Enemy.uasset b/Content/Enemy/BT_Enemy.uasset index 305b6ec..78e4eb1 100644 --- a/Content/Enemy/BT_Enemy.uasset +++ b/Content/Enemy/BT_Enemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a6c2275b337918471e6e71ea5f05a8d2dbf1607379e52169dfb08303d6ddc4e5 -size 7732 +oid sha256:231609c9a76a89d3bc175d9ddf1c2214d72e34cc192c951547b7e2850ce1355c +size 7474 diff --git a/Content/Levels/Level.umap b/Content/Levels/Level.umap index 90ea0cf..bc06626 100644 --- a/Content/Levels/Level.umap +++ b/Content/Levels/Level.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e31fda1b74670173ff696e7c1eb276b8fad398e54a3fcd9305bc9107d8e3e279 -size 65634 +oid sha256:c8eea2a5942b473a20b25487f8076c6a20149a5c588cada23d22231617045d81 +size 84020 diff --git a/Content/TestGoldPickup.uasset b/Content/TestGoldPickup.uasset new file mode 100644 index 0000000..6e328de --- /dev/null +++ b/Content/TestGoldPickup.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9eb996919b67f014150bdeef2949932d0f15a0231cc3e864b7f21df40035be89 +size 2442 diff --git a/Source/vampires/VampireAIController.cpp b/Source/vampires/VampireAIController.cpp index 2f294dc..f105058 100644 --- a/Source/vampires/VampireAIController.cpp +++ b/Source/vampires/VampireAIController.cpp @@ -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); +} diff --git a/Source/vampires/VampireAIController.h b/Source/vampires/VampireAIController.h index 8a2407e..3bd709a 100644 --- a/Source/vampires/VampireAIController.h +++ b/Source/vampires/VampireAIController.h @@ -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(); };