health var updates correctly on client when hit by projectile
This commit is contained in:
@@ -9,6 +9,7 @@ UDDIHealth::UDDIHealth()
|
||||
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
|
||||
// off to improve performance if you don't need them.
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
SetIsReplicatedByDefault(true);
|
||||
MaxHealth = 0;
|
||||
CurrentHealth = 0;
|
||||
ClassName = ClassNames::Scout;
|
||||
@@ -41,7 +42,7 @@ void UDDIHealth::BeginPlay()
|
||||
MaxHealth += seg;
|
||||
|
||||
CurrentHealth = MaxHealth;
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Cyan, FString::Printf(TEXT("CurrentHealth: %d"), CurrentHealth));
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Emerald, FString::Printf(TEXT("CurrentHealth: %d"), CurrentHealth));
|
||||
}
|
||||
|
||||
|
||||
@@ -81,10 +82,9 @@ void UDDIHealth::Heal()
|
||||
// Called to cause damage
|
||||
void UDDIHealth::TakeDamage(int DamageValue)
|
||||
{
|
||||
// if (HealTimer.IsValid())
|
||||
// HealTimer.Invalidate();
|
||||
GetWorld()->GetTimerManager().ClearTimer(HealTimer);
|
||||
|
||||
CurrentHealth -= DamageValue;
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Cyan, FString::Printf(TEXT("Client Hit\nHealth: %d"), CurrentHealth));
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user