I’m trying to register a sight sense with the perception stimuli source component and compiles fine but when I go to my Character and look at the PlayerStimuliSource component, there’s 0 senses registered.
PlayerCharacter.h
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Player)
class UAIPerceptionStimuliSourceComponent* PlayerStimuliSource;
Looking at the source code, RegisterForSense does extra-check for things that are not ready in the constructor of the character. Hence it exit the method before registering the Sense.
In the mean time, it seems that the editor (blueprint) has a direct access to the fields, that are protected for the C+±users:
Thus, the only way to workaround this is to create an inherited class:
In UMyAIP30t.h
UCLASS()
class THEPATHTOL0_API UMyAIP30t : public UAIPerceptionStimuliSourceComponent
{
GENERATED_BODY()
public:
UMyAIP30t (const FObjectInitializer& ObjectInitializer);
void RegisterSense(TSubclassOf<UAISense> SenseClass);
};
In UMyAIP30t.cpp
UMyAIP30t::UMyAIP30t(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
// Was set to false in the UAIPerceptionStimuliSourceComponent constructor.
bAutoRegisterAsSource = true;
}
void UMyAIP30t::RegisterSense(TSubclassOf<UAISense> SenseClass)
{
RegisterAsSourceForSenses.AddUnique(SenseClass);
}