Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Gameplay/Foes/MTD_FoeCharacter.h"
- #include "Components/CapsuleComponent.h"
- #include "FiniteStateMachine/FiniteStateMachine.h"
- #include "Gameplay/Foes/AI/States/MTD_FoeState_MovingAroundBlockade.h"
- #include "Gameplay/Foes/MTD_FoeController.h"
- AMTD_FoeCharacter::AMTD_FoeCharacter()
- {
- PrimaryActorTick.bCanEverTick = false;
- PrimaryActorTick.bStartWithTickEnabled = false;
- AIControllerClass = AMTD_FoeController::StaticClass();
- }
- void AMTD_FoeCharacter::PreInitializeComponents()
- {
- Super::PreInitializeComponents();
- UPrimitiveComponent* Collision = GetCapsuleComponent();
- Collision->OnComponentHit.AddDynamic(this, &ThisClass::OnCapsuleHit);
- }
- void AMTD_FoeCharacter::OnCapsuleHit(
- UPrimitiveComponent* HitComponent,
- AActor* OtherActor,
- UPrimitiveComponent* OtherComp,
- FVector NormalImpulse,
- const FHitResult& Hit)
- {
- if (!OtherActor->IsA(StaticClass()))
- {
- return;
- }
- const auto* FoeController = GetController<AMTD_FoeController>();
- check(IsValid(FoeController));
- UFiniteStateMachine* StateMachine = FoeController->GetStateMachine();
- check(IsValid(StateMachine));
- UMTD_FoeState_MovingAroundBlockade::MoveAroundBlockade(StateMachine, OtherActor, 0.f, Hit.Normal);
- }
Add Comment
Please, Sign In to add comment