x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

UAIPerceptionComponent Implementation help

Hello, So I am starting to create my enemies and I saw this AIPerceptionComponent. Every time I try to implement this system on my AI controller I get Errors. This is the code I found:

 SetPerceptionComponent(ObjectInitializer.CreateDefaultSubobject<UAIPerceptionComponent>(this, TEXT("Sense")));

These are the errors:

  d:\program files\unrealengine-4.13\engine\source\runtime\coreuobject\public\uobject\UObjectGlobals.h(760): error C2027: use of undefined type 'UAIPerceptionComponent'
 
  D:\Program Files\UnrealEngine-4.13\Engine\Source\Runtime\AIModule\Classes\AIController.h(24): note: see declaration of 'UAIPerceptionComponent'
 
  D:\Documents\Unreal Projects\HorrorGame 4.13 - 2\Source\HorrorGame\MobAI.cpp(8): note: see reference to function template instantiation 'TReturnType *FObjectInitializer::CreateDefaultSubobject<UAIPerceptionComponent>(UObject *,FName,bool) const' being compiled
            with
           [
               TReturnType=UAIPerceptionComponent
          ]
 
 d:\program files\unrealengine-4.13\engine\source\runtime\coreuobject\public\uobject\UObjectGlobals.h(760): error C3861: 'StaticClass': identifier not found
 
 d:\program files\unrealengine-4.13\engine\source\runtime\coreuobject\public\uobject\UObjectGlobals.h(761): error C2440: 'static_cast': cannot convert from 'UObject *' to 'UAIPerceptionComponent *'
 
 d:\program files\unrealengine-4.13\engine\source\runtime\coreuobject\public\uobject\UObjectGlobals.h(761): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast








Product Version: UE 4.13
Tags:
more ▼

asked Oct 15 '16 at 04:30 PM in C++ Programming

avatar image

joelComberiati
122 26 22 29

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

The compiler tries to tell you it has no idea what UAIPerceptionComponent is. You need to include its header, like so:

#include "Perception/AIPerceptionComponent.h"

Cheers,

--mieszko

more ▼

answered Oct 15 '16 at 07:05 PM

avatar image

MieszkoZ STAFF
7.4k 225 57 414

avatar image joelComberiati Oct 15 '16 at 08:16 PM

Oh, Wow, I cannot believe I did not think of that.Thank You worked like a charm.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question