Hey Guys,
I have been playing around with the ability system which seems pretty cool. There is a plethora of things that I don’t understand about it yet but I have it working. I hit a bit of a roadblock and I’m hoping someone can help me out.
I have a bunch of AIs in the game that fight each other by applying gameplay effects for damage. It all seems to work just fine on the server but the attributes don’t appear to be replicated to clients. I have some relevant parts shown below but let me know if there’s anymore that might be needed. I appreciate any help.
Here is what my AttributeSet class looks like:
UCLASS(Blueprintable, BlueprintType)
class RTSPROTOTYPE_API URTS_UnitAttributeSet : public UAttributeSet
{
GENERATED_UCLASS_BODY()
public:
URTS_UnitAttributeSet(FUnitAttributeData& Attributes);
public:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated, Category = "Attributes")
float Health;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated, Category = "Attributes")
float HealthMax;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated, Category = "Attributes")
float AttackDamage;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated, Category = "Attributes")
float AttackRange;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated, Category = "Attributes")
float AttackDelay;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated, Category = "Attributes")
float MovementSpeed;
};
URTS_UnitAttributeSet::URTS_UnitAttributeSet(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
, Health(0.f)
, HealthMax(100.f)
, AttackDamage(0.f)
, AttackRange(0.f)
, AttackDelay(0.f)
, MovementSpeed(0.f)
{
}
URTS_UnitAttributeSet::URTS_UnitAttributeSet(FUnitAttributeData& Attributes)
: Health(Attributes.Health)
, HealthMax(Attributes.HealthMax)
, AttackDamage(Attributes.AttackDamage)
, AttackRange(Attributes.AttackRange)
, AttackDelay(Attributes.AttackDelay)
, MovementSpeed(Attributes.MovementSpeed)
{
}
void URTS_UnitAttributeSet::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(URTS_UnitAttributeSet, Health);
DOREPLIFETIME(URTS_UnitAttributeSet, HealthMax);
DOREPLIFETIME(URTS_UnitAttributeSet, AttackDamage);
DOREPLIFETIME(URTS_UnitAttributeSet, AttackRange);
DOREPLIFETIME(URTS_UnitAttributeSet, AttackDelay);
DOREPLIFETIME(URTS_UnitAttributeSet, MovementSpeed);
}
Here is how I apply the damage.