0
\$\begingroup\$

I have this error, yet the game works and that variable ActorThatOpens get assigned correctly.

enter image description here

In my header the includes are:

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Engine/TriggerVolume.h"
#include "OpenDoor.generated.h"

As far as I can tell from the docs Components/ActorComponent.h contains the function GetWorld().

I have to go work now, but been scratching my head over this for an hour or so, and will continue to when i get home later. If anyone can see what I am doing wrong and can help I will be so grateful.

(As you can probably tell I am completely new to C++) THANKS!

\$\endgroup\$
2
  • \$\begingroup\$ It's a great and correct answer from Josh but if you do want to get rid of the Intellisense error, at the expense of slightly longer compile times, you can add #include "Engine/World.h" with all your other includes. \$\endgroup\$
    – Stephen
    Commented Jul 22, 2019 at 8:54
  • \$\begingroup\$ thanks Stephen , I did discover about Engine/World.h but when I added it I started getting errors on one of the built-in Macro that came from Unreal. Again , the game was compiling and working under these circumstances also. I think the order of the includes must be very important. What I am gonna do is keep my code super simple and ouside of any game engine until i learn exactly how to use includes properly (and more about c++ in general) . Then hopefully I will understand the docs a bit more for the engine once I try use it again. \$\endgroup\$ Commented Jul 22, 2019 at 12:41

1 Answer 1

4
\$\begingroup\$

This is another instance of Visual Studio’s Intellisense failing to properly parse Unreal code because it doesn’t have all the information.

If your code is actually compiling when you hit “Build,” you can safely ignore these sorts of “errors” from Intellisense. You can also disable the “red squiggly” feature entirely to stop it from distracting you.


Unreal projects in Visual Studio don't actually build through the usual Visual Studio mechanism. They are configured to tell VS to invoke an external build tool specific to Unreal called "UnrealBuildTool." This tool is responsible for supplying a lot of command-line arguments to the actual compiler (cl.exe) that the IDE itself doesn't know about. This occasionally leads the IDE to thinking that you've got code that can't compile, even though it will eventually compile fine once UnrealBuildTool sets the right options.

Sometimes you can fix this by deleting the .vs folder next to your .sln file. Note that this will delete some other customizations you've made to your solution file.

\$\endgroup\$
4
  • \$\begingroup\$ thank you for the plain english answer. It's a shame this happens like this, as when learning on my own it is easy to waste hours on this and lose track of the original things I was trying to learn lol. I somehow got rid of the error by some kind of witchcraft... well i THINK it was moving the ActorComponent include to be below the Engine one. But regardless I have stepped back a level and am back creating a Console app in visual studio only with a tutorial . Thanks again for your help here \$\endgroup\$ Commented Jul 22, 2019 at 2:48
  • \$\begingroup\$ If you don't know C++, using it with Unreal is probably not the best way to learn it, unfortunately. Unreal brings a lot of Unreal-specific baggage you wouldn't have to deal with learning C++ "on it's own," and which does not necessarily apply anywhere else you'd use C++. So that may be a good approach for you. Good luck. \$\endgroup\$
    – user1430
    Commented Jul 22, 2019 at 3:07
  • \$\begingroup\$ Sad really as I can make quite a lot of stuff quickly in Unity but I really do want to learn C++ so will keep persevering. Would you think SDL2 or SFML are still worth me looking at (I used them many years ago when i first attempted to learn game programming, but back then i understood nothing and gave up almost immediately). I kinda figured SDL2/SFML had been superseded by Unreal Engine. (Note I am purely wanting to learn, not make commercial quality prototypes etc right now haha) \$\endgroup\$ Commented Jul 22, 2019 at 3:42
  • \$\begingroup\$ Those seem like fine options. \$\endgroup\$
    – user1430
    Commented Jul 22, 2019 at 4:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .