I’m trying to write a class containing miscellaneous functions to get things like the angle between two vectors or the date and time or whatever.
My header looks like this:
float GetAngleBetweenVectors(FVector from, FVector to, FVector UpDir); // returns an angle from 0 to 360
int AngleDirection(FVector from, FVector to, FVector UpDir); // 0 = same angle, 1 = to the right, -1 = to the left
When I try to #include “UtilityFunctions.h” in my ThirdPersonCharacter.cpp file, it gets the squiggly saying it cannot open the source file. I think this has to do with where in the VS solution project tree I am placing the UtilityFunctions files. Where should they go? I’ve tried leaving them in the Source and the ThirdPerson directories.
Thanks for clarifying. I right clicked the .uproject file in the solution explorer but I couldn’t find an option to regenerate project files.
VS place code files where the VS project files are (in Intermittent directory), but Unreal use custom build system called UBT (something like “make”, managing VS compiler) which compliantly ignores project files and instead compiles according to C# build scripts you can find in source directory. I think best way is to make cpp and h files in source and then regenerate project files (right click uproject and there should be option for that). Also i think in 4.3 there will be option to create non-UObject class in “Add Code” so it will b easier to do such class without problems.
Extra hints looking on code:
-By engine convention all non-UObject classes have “F” prefix
-You seem to include cmath and Vector.h, try to avoid using standard liberies and use UE4 API as much as possible (FMath insted of Math, TArray, TMap etc for containers) use them only in last resort (you probably need to use them when you play with external libs), so you 100% sure that your code will build and work the same on any platform that UE4 supports. Not to mention standard liberties are not compatible with Blueprint and editor environment
Do it in explorer ;p If you compiled from source and you dont see options even in explorer, run Engine/Bineries/Win64/UnrealVersionSelector-Win64-Shipping.exe
Also extra hint i missed, use static functions so you dont need to instantiate UtilityFunctions class
Thank you for that hint. I regenerated project files, and it moved my .h and .cpp into the Intermediate folder but it still does not want to include my header.
The files aren’t in the tree anymore so I guess it makes sense that they can’t be included.
Hmm can you paste error here and your project file tree map (screen?:p) ?
It needs to be in source directory, where all code is, place it where ThirdPerson.h is