I am programming in ue5 and i was creating a spatial hash. i needed to have a declared cell size for the hash, and i decided to use the constructor
Here is a similar code
HSpatialHash.h
UCLASS()
class xxx_API UHSpatialHash final : public UObject
{
GENERATED_BODY()
public:
explicit UHSpatialHash(const float PCellSize) {CellSize = PCellSize;}
}
Error message:
error C:\Users\user\OneDrive\Documents\Unreal Projects\attrition\Source\project name\Private\HSpatialHash.h(18):
error C2338: static_assert failed: 'You have to define UHSpatialHash::UHSpatialHash() or UHSpatialHash::UHSpatialHash(const FObjectInitializer&).
This is required by UObject system to work correctly.'
I tried to add the FObjectInitializer parameter, but it didn't work. I tried to put in in the cpp file, nothing, i don't know what to do. Can you help me?