The problem with the character

Hey. I create an instance of HealthStats (child class ActorComponent) in my character and try to reduce the character’s health through HealthStats-> SetHealth (50); but I have nothing. I also tried to create a character and bluprint change through bluprint, but I just could not. I can not even PrintString!

Can you show us the constructor of your character, the “.h” file and the implementation of your HealthStats class

You should have an actor or your character with a HealthStats as an attribute.

Then in its beginPlay method you should have something to create it, a call to
FObjectInitializer::CreateDefaultSubobject

UHealthStatComponent*  Mycomponent = CreateDefaultSubobject<UHealthStatComponent>(TEXT("Health"))

here a tuto

This is a standard ThirdPersonCharacter.
I’ll play around and realized that the problem in the standard character, as if I create a pure class that inherits from the character, I have everything works fine!
That class HealthStats:
class THIRDPERSON_API UHealthStats: public UActorComponent
{
GENERATED_BODY ()

public:
// Sets default values for this component’s properties
UHealthStats ();

// Called when the game starts
virtual void BeginPlay () override;

// Called every frame
virtual void TickComponent (float DeltaTime, ELevelTick TickType, FActorComponentTickFunction * ThisTickFunction) override;

UFUNCTION ()
void SetHealth (float health) {Health = health; }; // Set HP

UFUNCTION ()
float GetHealth () {return Health; }; // Get HP

UFUNCTION ()
void ChangeHealth (float Value);

UFUNCTION ()
void DisplayStats ();

private:

UPROPERTY ()
float Health = 100.0f; //Health
};