the line of code that is breaking
UStoredResource result = UStoredResource(resource, quantity);
and this is my h file discluding includes
UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class RESOURCESYSTEM_API UStoredResource : public UObject
{
GENERATED_BODY()
public:
UStoredResource();
UStoredResource(UResource* resource, int quantity) {
this->resource = resource;
this->quantity = quantity;
}
UPROPERTY(EditAnywhere)
UResource* resource;
UPROPERTY(EditAnywhere)
int quantity;
bool UStoredResource::operator==(const UStoredResource& other) const {
if (other.resource == resource) return true;
else return false;
}
};
my bad did not realize the formatting system would do that
is there a different class that i could inherit from and unreal still be ok with the class existing my main concern being that it doesn’t need to be an actor or anything of that nature as the item is purely a data structure
Since your class is a subclass of a UObject you can’t call constructors or pass parameters at all. Short story is that the reflection system doesn’t allow for it. One option is to add an init function that you can pass parameters into that you call after using NewObject() to properly spawn your object. Another option is to create a static function with parameters in your class that does the previous option, but all from one call.
If it’s purely a data structure, take a look at USTRUCTS. They allow for constructors with parameters, but also show up in the editor and have a bunch of neat features.