Value Not Being Set In Constructor

I have a two floats ‘StartingHitPoints’ and ‘HitPoints’, in the constructor of my actor class I set HitPoints = StartingHitPoints.

StartingHitPoints Is exposed with EditAnywhere and Hitpoints VisibleAnywhere.

I have a BP class which inherits from my CPP class so I can add Arty stuff like particles, but when i change StartingHitPoints it does not chnage HitPoints.

What is the issue, or is this just an underlying Unreal thing I have to work around?

Many Thanks Folks…

Make A new function in your .h file call it whatever like



void SetHitPoints();

add this to your .h file


//Begin UObject Interface
#if WITH_EDITOR
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif // WITH_EDITOR
//End UObject Interface
};

In your cpp file add in



void yourcalsssname::SetHitPoints()
{
    HitPoints = StartingHitPoints;
}


Also in the in your cpp file add



#if WITH_EDITOR
void AOutOfBoundsVolume::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
     Super::PostEditChangeProperty(PropertyChangedEvent);
     SetHitPoints();
}
#endif


When you edit the1st number, second will take 1st numbers setting.

gamepainters…

Worked a treat thanks

np, glad it works for you.