Of course sorry about the confusion, here are the functions in call order. Basically what I am doing is I first check if the player is entering combat, if so I just equip the main weapon. If the player is already in combat (meaning they have a weapons equipped) I first unequip the main weapons and once that action/animation is over I equip the off weapon.
void AArenaCharacter::EquipWeapon(AArenaRangedWeapon* ToEquip, AArenaRangedWeapon* ToUnEquip, bool IsEnteringCombat)
{
if (ToEquip)
{
if (Role == ROLE_Authority)
{
if (IsEnteringCombat == true)
{
SetCurrentWeapon(ToEquip, ToUnEquip);
FinishEquipWeapon();
}
else
{
SetCurrentWeapon(ToEquip, ToUnEquip);
StartEquipWeapon();
GetWorldTimerManager().SetTimer(this, &AArenaCharacter::FinishEquipWeapon, 1.5f, false);
}
}
else
{
ServerEquipWeapon(ToEquip, ToUnEquip, IsEnteringCombat);
}
IsEnteringCombat = false;
}
}
So if this was initiated by the client, the logic is passed off for the server:
bool AArenaCharacter::ServerEquipWeapon_Validate(AArenaRangedWeapon* ToEquip, AArenaRangedWeapon* ToUnEquip, bool IsEnteringCombat)
{
return true;
}
void AArenaCharacter::ServerEquipWeapon_Implementation(AArenaRangedWeapon* ToEquip, AArenaRangedWeapon* ToUnEquip, bool IsEnteringCombat)
{
EquipWeapon(ToEquip, ToUnEquip, IsEnteringCombat);
}
The above basically just calls the same function but on the server. The last call happens inside “StartEquipWeapon()” which calls the following function in the weapon calss:
void AArenaRangedWeapon::OnHolster(bool IsPrimary)
{
if (MyPawn)
{
// For locally controller players we attach both weapons and let the bOnlyOwnerSee, bOwnerNoSee flags deal with visibility.
FName AttachPoint;
if (IsPrimary == true)
{
bPendingHolster = true;
float Duration = PlayWeaponAnimation(HolsterAnim);
if (Duration <= 0.0f)
{
Duration = 0.5f;
}
GetWorldTimerManager().SetTimer(this, &AArenaRangedWeapon::OnHolsterPrimary, FMath::Max(0.1f, Duration - 0.70f), false);
}
if (IsPrimary == false)
{
bPendingHolster = true;
float Duration = PlayWeaponAnimation(HolsterAnim);
if (Duration <= 0.0f)
{
Duration = 0.5f;
}
GetWorldTimerManager().SetTimer(this, &AArenaRangedWeapon::OnHolsterSecondary, FMath::Max(0.1f, Duration - 0.70f), false);
}
}
}