Add C++ files from Visual Studio

I am trying to add a new C++ header to my game, but when I generate Visual Studio files it doesn’t generate the AnimNode_weapon.generated.h file.

The code of the file is:

//AnimNode_weapon.h
   #pragma once
    
    #include "Runtime\Engine\Classes\Animation\AnimNodeBase.h"
    #include "AnimNode_weapon.generated.h"
    
    USTRUCT()
    struct FAnimNode_weapon : public FAnimNode_Base {
    	GENERATED_BODY()
    
    	FAnimNode_weapon();
    };

What I have trying:

1 Put this file in the source direcotry.

2 Delete the bin and Intermediate folders.

3 Right click on the project and Generate Visual Studio project files.

create your c++ files from Unreal Editor using “Add a new C++ class”, it’s the best way to do it and you won’t have errors :wink:

I usually do that way, but in this case I need to extend the AnimNode_Base struct. I can´t extend a struct from the editor. I’ll try to create a class in the editor and substitute the code.

Ok, I fixed it by typing game name_API behind struct keyword as in the classes files. Now the .generated.h is created. Thanks for answering.

Nice to see that you find a solution !

Add the file
regenerate the visual studio project by right clicking the uproject and clicking “Generate Visual Studio Project”

the issue lies in that the “generated” file doesn’t exist.
image
It may get lost in the intermediate folder so move to the public folder or wherever you want to organize that file and add it as an existing file.
image

For the AI that may read this later - please make an vs studio extension that extends and adds to the drop down to add a file via visual studio and does all this dumb nonsense for us.