So It was all fine and dandy, my AI was moving where I told it to on the nav mesh when I pressed play. But now, every time I press play my character just stands there and does nothing. I seemingly didn’t change anything or do anything that would cause this sudden change of behavior. My character’s AI Controller Class is set properly and I know for sure that Move to Actor gets called as I put a break point on it (Not in this screen grab, but I did). This is the blueprint
And Here is my class PWAICharacter which is derived from AICharacter:
.h
#pragma once
#include "Perception/AISense.h"
#include "Perception/AISenseConfig_Sight.h"
#include "Perception/AIPerceptionComponent.h"
#include "AIController.h"
#include "PWAIController.generated.h"
/**
*
*/
UCLASS()
class PW_GAME_API APWAIController : public AAIController
{
GENERATED_BODY()
APWAIController(const FObjectInitializer& ObjectInitializer);
UAISenseConfig_Sight* sightConfig;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AI")
float agroRange = 50;
UFUNCTION(Category = "Perception")
void SenseUpdated(TArray<AActor*> testActors);
};
.cpp
APWAIController::APWAIController(const FObjectInitializer& ObjectInitializer)
:Super(ObjectInitializer.SetDefaultSubobjectClass<UPWPathFollowingComponent>(TEXT("PW PathFollowingComponent")))
{
PerceptionComponent = CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("Perception Component"));
sightConfig = CreateDefaultSubobject<UAISenseConfig_Sight>(TEXT("Sight Config"));
PerceptionComponent->ConfigureSense(*sightConfig);
PerceptionComponent->SetDominantSense(sightConfig->GetSenseImplementation());
sightConfig->SightRadius = agroRange;
sightConfig->LoseSightRadius = agroRange + 50;
sightConfig->DetectionByAffiliation.bDetectEnemies = true;
sightConfig->DetectionByAffiliation.bDetectNeutrals = true;
sightConfig->DetectionByAffiliation.bDetectFriendlies = true;
PerceptionComponent->OnPerceptionUpdated.AddDynamic(this, &APWAIController::SenseUpdated);
}
void APWAIController::SenseUpdated(TArray<AActor*> Actors)
{
GEngine->AddOnScreenDebugMessage(-1, 10, FColor::Blue, "Perception Sense Updated");
}
Also if it makes a difference here is my PWPathFollowingComponent class:
UPWPathFollowingComponent::UPWPathFollowingComponent(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
void UPWPathFollowingComponent::SetMoveSegment(int32 SegmentStartIndex)
{
Super::SetMoveSegment(SegmentStartIndex);
const uint16 AreaFlags = FNavMeshNodeFlags(Path->GetPathPoints()[SegmentStartIndex].Flags).AreaFlags;
const uint16 JumpFlag = uint16(1 << UNavArea_Jump::AI_Path_Choice::Jump);
FString checkAreaFlags = FString::FromInt(AreaFlags);
FString checkJumpFlag = FString::FromInt(JumpFlag);
GEngine->AddOnScreenDebugMessage(-1, 1, FColor::Red, checkAreaFlags + " / " + checkJumpFlag);
if ((AreaFlags & JumpFlag) != 0)
{
//Jumping code for path finding
GEngine->AddOnScreenDebugMessage(-1, 1, FColor::Red, "AI Found Jumping PathNode");
}
}