void AHeroController::Damage_Implementation(FDamageParams **params**) {
***// params.PrevHealth, and all values inside params are reset to 0!***
HealthBar_ins->SetScalarParameterValue("Prev", **params.PrevHealth**);
HealthBar_ins->SetScalarParameterValue("Cur", Pawn->CurHealth);
}
The struct works fine to be passed all around, but the moment it passes through an interface function it gets completely reset.
How can I solve this?
That’s not how passing by value works anywhere. It should copy the struct with the values that are set into. It doesn’t (or shouldn’t) copy “with default data”.
Making it a UPROPERTY (and restarting unreal) allowed the property to persist through the interface.
But thanks for the info guys, I didn’t even think about passing as a reference, that would have most likely worked as well!
Might actually go back someday and change many things into references where relevant.
Edit: Turns out I added UPROPERTY on a different value, NOT on PrevHealth, even though it randomly started working the next day. Just Unreal being Unreal I guess.