void ASCharacter::SetCurrentWeapon(class ASWeapon* NewWeapon, class ASWeapon* LastWeapon) { /* Maintain a reference for visual weapon swapping */ PreviousWeapon = LastWeapon; ASWeapon* LocalLastWeapon = nullptr; if (LastWeapon) { LocalLastWeapon = LastWeapon; } else if (NewWeapon != CurrentWeapon) { LocalLastWeapon = CurrentWeapon; } // UnEquip the current bool bHasPreviousWeapon = false; if (LocalLastWeapon) { LocalLastWeapon->OnUnEquip(); bHasPreviousWeapon = true; } CurrentWeapon = NewWeapon; if (NewWeapon) { NewWeapon->SetOwningPawn(this); /* Only play equip animation when we already hold an item in hands */ NewWeapon->OnEquip(bHasPreviousWeapon); } /* NOTE: If you don't have an equip animation w/ animnotify to swap the meshes halfway through, then uncomment this to immediately swap instead */ //SwapToNewWeaponMesh(); }
void ASCharacter::SetCurrentWeapon(class ASWeapon* NewWeapon, class ASWeapon* LastWeapon) { ASWeapon* LocalLastWeapon = nullptr; if (LastWeapon) { LocalLastWeapon = LastWeapon; } else if (NewWeapon != CurrentWeapon) { LocalLastWeapon = CurrentWeapon; } // UnEquip the current if (LocalLastWeapon) { LocalLastWeapon->OnUnEquip(); } CurrentWeapon = NewWeapon; if (NewWeapon) { NewWeapon->SetOwningPawn(this); NewWeapon->OnEquip(); } }