70 - Fire Effects in Multiplayer
This commit is contained in:
parent
cd21cd9366
commit
85c074d97e
Binary file not shown.
|
@ -17,6 +17,14 @@ UCombatComponent::UCombatComponent()
|
|||
AimWalkSpeed = 350.f;
|
||||
}
|
||||
|
||||
void UCombatComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
||||
{
|
||||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||
|
||||
DOREPLIFETIME(UCombatComponent, EquippedWeapon);
|
||||
DOREPLIFETIME(UCombatComponent, bAiming);
|
||||
}
|
||||
|
||||
void UCombatComponent::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
@ -58,8 +66,22 @@ void UCombatComponent::OnRep_EquippedWeapon()
|
|||
void UCombatComponent::FireButtonPressed(bool bPressed)
|
||||
{
|
||||
bFireButtonPressed = bPressed;
|
||||
|
||||
if (bFireButtonPressed)
|
||||
{
|
||||
ServerFire();
|
||||
}
|
||||
}
|
||||
|
||||
void UCombatComponent::ServerFire_Implementation()
|
||||
{
|
||||
MulticastFire();
|
||||
}
|
||||
|
||||
void UCombatComponent::MulticastFire_Implementation()
|
||||
{
|
||||
if (EquippedWeapon == nullptr) return;
|
||||
if (Character && bFireButtonPressed)
|
||||
if (Character)
|
||||
{
|
||||
Character->PlayFireMontage(bAiming);
|
||||
EquippedWeapon->Fire();
|
||||
|
@ -72,14 +94,6 @@ void UCombatComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActo
|
|||
|
||||
}
|
||||
|
||||
void UCombatComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
||||
{
|
||||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||
|
||||
DOREPLIFETIME(UCombatComponent, EquippedWeapon);
|
||||
DOREPLIFETIME(UCombatComponent, bAiming);
|
||||
}
|
||||
|
||||
void UCombatComponent::EquipWeapon(AWeapon* WeaponToEquip)
|
||||
{
|
||||
if (Character == nullptr || WeaponToEquip == nullptr) return;
|
||||
|
|
|
@ -33,6 +33,12 @@ protected:
|
|||
|
||||
void FireButtonPressed(bool bPressed);
|
||||
|
||||
UFUNCTION(Server, Reliable)
|
||||
void ServerFire();
|
||||
|
||||
UFUNCTION(NetMulticast, Reliable)
|
||||
void MulticastFire();
|
||||
|
||||
private:
|
||||
class ABlasterCharacter* Character;
|
||||
|
||||
|
|
Loading…
Reference in New Issue