Thanks! This helped me out a lot too!
Hi!
Your solution works too and of course, you don’t need to replace the CoreMinimal or delete it from the code. As you can see here https://docs.unrealengine.com/latest/INT/Programming/UnrealBuildSystem/IWYUReferenceGuide/ (go to “IWYU Conventions”), CoreMinimal contains “generic” types, the reason why I’m replacing it is because we are not using those types in our class. If you select CoreMinimal.h in VS, right click on it and select “Open document CoreMinimal.h”, you can see all the headers that it has inside, so you can determine if you need to include the header. Anyway, I recommend to include the CoreMinimal.h in the next classes to avoid future problems!
Hey! Thanks for the info! Never hurts to know more!
So I’ve had the same problem as everyone else. ATriggerVolume wasn’t recognized. I googled it and found that it lives in Engine/TriggerVolume.h, so I included that. ATriggerVolume is now recognized, but all sorts of other things aren’t recognized anymore. I moved the .h file before any of the generated.h files. I still get 6 errors. However, when I build the solution, I hear Unreal do a hot load when it’s done, and the pressure plate option is there. Is there any way to get rid of these errors? I’ll never know if I’ve got a clean compile if they show up every time.
Thanks for listening.
Larry
This solution worked for me! Once you save and compile from Unreal I notice that after I re-open OpenDoor.h the UCLASS is no longer complaining about “Declaration has no storage…” with in Visual Studio.
Unreal Engine told me that #include “Engine/TriggerVolume.h” needed to be placed above any .generated file in the #includes. .generated files always come last it says. After I resorted my #includes accordingly the #include “Engine/TriggerVolume.h” worked, VS saw the triggervolume.
Also the generated file had some mysterious spacing bugs in UCLASS that were creating some red squigglies, when I just spaced the line a bit the errors went away and the Pressure Plate showed up correctly with no errors.
Below is code update for UE4 4.16.2. This worked perfectly for me, should also for anyone using this version too. The amazingly easy to read UE4 error messages helped me out here.
#include “Engine/TriggerVolume.h” in OpenDoor.h as a first, so it will look like this:
#include “Engine/TriggerVolume.h”
#include “CoreMinimal.h”
#include “Components/ActorComponent.h”
#include “OpenDoor.generated.h”
And make sure there is only one empty line beetwen include and UCLASS in the same file!
Definitely don’t use #include “Engine.h” . This will ruin your compile times. Instead, use #include “Engine/TriggerVolume.h”, so you won’t be importing a ridiculous amount of data. In fact, you should never use Engine.h, As it’ll slow you down. Try to be as specific as possible and only include files you absolutely need.
Make Sure your UCLASS is only one line away from your includes or VS/Xcode will flip at you.
Thank you!
I had been struggling with this for hours.
I did what was suggested, and added #include “Engine/TriggerVolume.h” above .generated.h and after CoreMinimal.h.
I was still getting a bunch of random errors, such as GENERATED_BODY() being marked as incorrect, and random errors all over the place. I also got an error when compiling it in the Unreal Engine also. It gave the error that there needed to be a ‘;’ after Atriggervolume.
It turns out it was because I used lowercase for the declaration on accident. Went back and made the T in Trigger, and V in volume capital and everything worked.
UPROPERTY(EditAnywhere)
Atriggervolume* PressurePlate;
After fix:
UPROPERTY(EditAnywhere)
ATriggerVolume* PressurePlate;
I figured I would mention this because a lot of the errors I was getting sounded like what others were getting before I fixed the capitalization, but I didn’t see it mentioned, so I figured I would throw this out there also.
Hi, I have a bit simular problem with my code after updating visual studio… Could someone please please! help me find out what to do? I’ve been stuck with this for a week. Ben is not reacting and google answers did not help me either.
EDIT: I Fixed the problem never mind. Just regenerate the whole project from the folder.
I have a slightly better solution to this issue. Instead of compiling within VS, just close all files you are using in VS and then close VS. Within the UE Editor, hit the compile button to compile the C++ code. Then open your VS using File -> Open Visual Studio. Now you can see that Intellisense is working once again.
I’m currently using Visual Studio 2017 Community (VS), with the UE4 Intellisense plugin, and Visual Commander plugin to implement hackalyze’s ue4-vs-extensions (found at https://github.com/hackalyze/ue4-vs-extensions).
Unreal Engine 4.17.2 (UE), though all of this is tested also on UE 4.16.3.
I left the original post below so you know what happened wrong.
My actions that I suggested below really messed things up for me! Shame on me for not fully testing my suggestion. The following is what I am doing now to fix everything…
I have noticed that every time you change something in the source files above the UClass line, VS IntelliSense forgets everything! This is quite annoying. On top of this, GetWorld()-> autocomplete never worked until I did what I am now suggesting.
After editing all includes and saving the edits, close all open documents (the .cpp and .h files).
- Rebuild the solution by going to Build -> Rebuild Solution
- Close Visual Studio and go back to the Unreal Editor
- Refresh the Visual Studio Project by going to File -> Refresh Visual Studio Project
- Open the Visual Studio Project by going to File -> Open Visual Studio
At this point, the autocomplete should be working. For me to get the GetWorld()-> to autocomplete I had to include “Engine/World.h”. I have been placing all include statements within the header file of the class I am working on.
I hope this helps. And do not do what I suggested at this point unless you know how to recover from it properly.
Original
Sometimes IntelliSense is messed up. Within your project folder, there is a .vs folder. This is auto-generated when you compile the project. If rebuilding the whole solution does not work, then attempt a simple close and reopen the solution (or just close and restart Visual Studio). If this does not work, then delete the .vs folder. An easy way to get to the solution folder is to right-click the Solution in the Solution Explorer and go to Open Folder in File Explorer near the bottom of the menu. With that open, close Visual Studio, and then delete the .vs folder. Then you can reopen Visual Studio like normally, allow it to parse the files in the solution (you deleted this) and then all will be good!
Note: You might need to change the solution platform back to Win64 or Win32 after doing this. That way you can recompile within Visual Studio without issue.
The Menu
Parse Indicator at bottom of Visual Studio window
This is my header - the #include “Engine.h” fixed it, however, #include 'OpenDoor.generated.h" must be last. Otherwise an error is returned on compile
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Engine.h"
//Must be last
#include "OpenDoor.generated.h"
Using this works, but is bad practice.
From:
James Golding
@EpicJamesG
Lead Programmer - Animation + Physics, Unreal Engine 4, Epic Games
Why is it bad practise? What should I change it to/put in it’s place
Look over the course once again, you may find that the lecture numbers have changed. Lecture “64. Include What You Sue For 4.17+” explains it very well. This information is actually true right before the 4.17 release (very applicable during the 4.16 cycle). Also you can look at the links I provided to know what is the good practice.
Include-What-You-Use (IWYU), as the name implies, means that the Engine’s source code only includes the dependencies that it needs to compile. The purpose of IWYU is to avoid including monolithic header files, such as Engine.h or UnrealEd.h, thereby mitigating superfluous dependencies. The following reference guide tells you what it means to IWYU, including a high-level explanation of how to enable IWYU, ensuring that your project adheres to IWYU conventions. Additionally, if you opt into using IWYU mode for your game project(s), you will learn some general tips that will help you get the most out of working in IWYU mode.
Source: https://docs.unrealengine.com/latest/INT/Programming/UnrealBuildSystem/IWYUReferenceGuide/
Another elegant solution is to use forward class declaration in your header file and use the #include in your CPP file.
For bigger projects this may reduce considerably the compilation time…
Your solution is the most optimal. Thank you very much friend! Also to anyone having problems still even after the code is recognized by VS. You must fix this
ATriggerVolume* PressurePlate; to
ATriggerVolume *PressurePlate;
As Ben stated early in the courses, that is the proper way to code pointers in Unreal. VS may understand it the other way, but Unreal does not like it.