Advertisement
Guest User

MTD_FoeCharacter.cpp

a guest
Oct 11th, 2023
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include "Gameplay/Foes/MTD_FoeCharacter.h"
  2.  
  3. #include "Components/CapsuleComponent.h"
  4. #include "FiniteStateMachine/FiniteStateMachine.h"
  5. #include "Gameplay/Foes/AI/States/MTD_FoeState_MovingAroundBlockade.h"
  6. #include "Gameplay/Foes/MTD_FoeController.h"
  7.  
  8. AMTD_FoeCharacter::AMTD_FoeCharacter()
  9. {
  10. PrimaryActorTick.bCanEverTick = false;
  11. PrimaryActorTick.bStartWithTickEnabled = false;
  12.  
  13. AIControllerClass = AMTD_FoeController::StaticClass();
  14. }
  15.  
  16. void AMTD_FoeCharacter::PreInitializeComponents()
  17. {
  18. Super::PreInitializeComponents();
  19.  
  20. UPrimitiveComponent* Collision = GetCapsuleComponent();
  21. Collision->OnComponentHit.AddDynamic(this, &ThisClass::OnCapsuleHit);
  22. }
  23.  
  24. void AMTD_FoeCharacter::OnCapsuleHit(
  25. UPrimitiveComponent* HitComponent,
  26. AActor* OtherActor,
  27. UPrimitiveComponent* OtherComp,
  28. FVector NormalImpulse,
  29. const FHitResult& Hit)
  30. {
  31. if (!OtherActor->IsA(StaticClass()))
  32. {
  33. return;
  34. }
  35.  
  36. const auto* FoeController = GetController<AMTD_FoeController>();
  37. check(IsValid(FoeController));
  38.  
  39. UFiniteStateMachine* StateMachine = FoeController->GetStateMachine();
  40. check(IsValid(StateMachine));
  41.  
  42. UMTD_FoeState_MovingAroundBlockade::MoveAroundBlockade(StateMachine, OtherActor, 0.f, Hit.Normal);
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement