Once the enemy get damage on the server, I will set its IncomingDamage value on the server, and I think it should call OnRep_IncomingDamage() automaticlly.
// server, notify enemy got damaged
void AAuraEnemy::NotifyGetIncomingDamage(float NewIncomingDamage)
{
IncomingDamage = NewIncomingDamage;
}
void AAuraEnemy::OnRep_IncomingDamage(float OldValue) const
{
// cosmatic UI things to do on the client.
OnIncomingChanged.Broadcast(IncomingDamage);
}
But I only got OnRep_IncomingDamage called once when the enemy got same IncomingDamage value
What’'s the problem, and how REPNOTIFY_Always works?
A few things to check, is your Actor Replicated and Is the Property a UPRoperty marked with ReplicatedUsing=OnRep_IncomingDamage.
The OnRep function should be called on all clients any time that value is changed on the Server. If you want it to always Notify and you dont have any condition you can instead use DOREPLIFETIME(AAuraEnemy, IncomingDamage) which would work the same way.
I have checked. This enemy is placed in the level, and I never set its owner, so it will nullptr.
My purpose is to damage the enemy and tell its damage information to all clients, and do some notify effects.
But I have test many times, it is only work for the first time unless its got different damage value.
By the way, the default value for FDoRepLifetimeParams is COND_None and REPNOTIFY_OnChanged no suitable for my needs.
Okay sorry I see the issue here. Yeah for what your wanting you probably want to look at Push based networking as even though your setting it to the same value you want to tell the client. For this you will want to look at DOREPLIFETIME_WITH_PARAMS and setting the params bIsPushBased to true. This way you then just call MARK_PROPERTY_DIRTY_FROM_NAME(ClassName, PropertyName, this); and it will force the push to the client