Unresolved external symbol when casting to AAIController

Try being explicit with the types instead of using “auto”. I don’t think it’s a good idea to use that within UE4 code.

1 Like

Wow that’s weird. Cuz it finds StopMovement… I’ll keep thinking.

If I cast an InstigatorController to AAIController I get those errors for no reason???
If I cast to actor to a pawn first and then cast the controller (GetController()) the same error happens.
I have included the AIController.h file.

Not using auto here does not change the resulting error.

StopMovment() is a function from Instigator Controller, not AIController.
I need to cast to AI controller because of the Move to Target function.

Now yes and it succeeded -.-
Thanks for the quick help.

I have to revise my statement:
Although when I klick clean sollution and then generate project files (after closing VS) I get an error, that unreal is unable to build the dll files.
Building the sollution from VS after a clean build will result in the same error as shown on the screenshot.

Did you try a rebuild from scratch (clean out the intermediate files)?
(Edit: You also have to “Generate Project Files” again)

You should try removing the files yourself. If you don’t know what you’re doing, copy your entire project in case you break something. But close everything, go into the project directory, and delete all the folders/files that were generated. Then regenerate project files and try again.

The folders/files you DO NOT want to get rid of are the uproject file, Config, Content, and Source. If you have plugins then you need to clean those out but not delete them entirely (obviously).

And maybe try rebuilding UE4 if you have the source version. I only say to try this because AAIController is a part of the engine. It doesn’t make sense that you would only get those 2 unresolved externals.

Other than that, I don’t know. It looks OK to me except for the auto stuff, which I try to avoid because UE4 uses a precompiler and it can cause issues with some C++ features (also, it’s good to be explicit for readability IMO).

Oh, wait. Show me your class declaration.

StopMovement() is a virtual function and is overridden in AAIController.

I have deleted the folders .vs, Binaries, Intermediate and Saved, as well as the .sln file → Same result.

I have copied the entire function in another project (commenting out the Curser line trace, because I didn’t had a PlayerController class there) and I didn’t get any errors.

I found the solution:
When you include AIModule.h file you need to add AIModule to the PublicDependencyModuleNames String in the [Project name].Build.cs files.

Seriously, why do you need to do that?

1 Like

I’ve never had to do that. They have been pushing things into plugins more and more, but not the core AI mechanisms AFAIK. Glad it’s fixed and good luck in the future! :slight_smile:

Did you already have these modules loading?

Core, CoreUObject, Engine, InputCore

Yes these modules where loaded by default, but not AIModule

Is it a C++ only project? Maybe mine is enabled by default because it’s using C++ and BPs. Otherwise, I have no idea why you’d need to do that.

It was a Blueprint project.

Weird. OK then. I guess I don’t understand why you need to include the module explicitly and I don’t. Are you sure you’re using 4.18.something? If it was 4.19 Preview then that would make sense because they might disable the AI module by default at some point. They’ve been making this transition with a lot of features over the past few versions.

Oh and which header are you including to get the AAController declaration?