If it can help : I tried to call LifeResource = NewObject(this)
but then the unreal editor crashed everytime. Here are the UResource files :
Resource.h file :
#pragma once
#include "Object.h"
#include "Resource.generated.h"
/**
* Main class for cooldowns, life and similar attributes
*/
UCLASS(Blueprintable)
class PROTOTYPEFPS_API UResource : public UObject, public FTickableGameObject
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere)
float ValueMin;
UPROPERTY(EditAnywhere)
float ValueMax;
UPROPERTY(EditAnywhere)
float InitValue;
UPROPERTY(EditAnywhere)
float Regeneration;
UPROPERTY()
float ActualValue;
UResource();
// Override FTickableGameObject functions
virtual void Tick(float DeltaTime) override;
virtual bool IsTickable() const override;
virtual TStatId GetStatId() const override;
UFUNCTION()
void AddValue(float Value);
UFUNCTION()
bool IsEmpty() const;
UFUNCTION()
bool IsFull() const;
UFUNCTION()
void ResetMaxValue(float NewMax);
};