Extending UAIPerceptionSystem

Hey there,
I’m trying to extend the AI Perception System to use some new actors to be noticed by the system (UAISystem::OnActorSpawned notifies only about Pawns so far).

I’m simply extending the UAIPerceptionSystem:

Header:




#pragma once

#include "Perception/AIPerceptionSystem.h"
#include "MyAIPerceptionSystem.generated.h"

UCLASS()
class UMyAIPerceptionSystem : public UAIPerceptionSystem
{
    GENERATED_BODY()
};

I get errors in the AIPerceptionSystem.h when compiling:



Runtime/AIModule/Classes/Perception/AIPerceptionSystem.h:102:30: error: incomplete type 'UAISense' named in nested name specifier

Runtime/AIModule/Classes/Perception/AIPerceptionSystem.h:102:84: error: expected '(' for function-style cast or type construction

Runtime/AIModule/Classes/Perception/AIPerceptionSystem.h:102:86: error: expected expression

Runtime/AIModule/Classes/Perception/AIPerceptionSystem.h:208:23: error: incomplete type 'UAISense' named in nested name specifier

Runtime/AIModule/Classes/Perception/AIPerceptionSystem.h:208:44: error: 'FSenseClass' does not refer to a value

Runtime/AIModule/Classes/Perception/AIPerceptionSystem.h:208:57: error: expected expression

Runtime/AIModule/Classes/Perception/AIPerceptionSystem.h:212:13: error: incomplete type 'UAISense' named in nested name specifier

Runtime/AIModule/Classes/Perception/AIPerceptionSystem.h:212:34: error: 'FSenseClass' does not refer to a value

Runtime/AIModule/Classes/Perception/AIPerceptionSystem.h:212:47: error: expected expression

Since it’s engine code, I’ve got no idea what’s happening ^^.

Any ideas?

What’s happening is Epic’s evil policy of including headers from cpp files and not directly from within other headers that require them.
You’ll need to #include “AISense.h”, and possibly some others.

Hm, thanks a lot for your answer. I’ve added all these headers:


#include "Perception/AISense.h"
#include "Perception/AIPerceptionTypes.h"
#include "AITypes.h"

Still I receive the same compile errors. : /

The AIModule is also added to my build dependencies… (Since I’m not using the public/private folder structure I’m always adding things to private dependency list).

Did you include those headers (AISense.h in particular) above the include for AIPerceptionSystem.h? Make sure you do.
If that still doesn’t solve it, I’m not sure what the issue is, but you could try posting your code more fully along with the complete build output.

Ah, thank you so much kamrann!!
Placing the AISense.h above AIPerceptionSystem.h did the trick…