diff --git a/Source/Nakatomi/PlayerCharacter.cpp b/Source/Nakatomi/PlayerCharacter.cpp index 51ffd8a..dcecbf4 100644 --- a/Source/Nakatomi/PlayerCharacter.cpp +++ b/Source/Nakatomi/PlayerCharacter.cpp @@ -602,23 +602,25 @@ float APlayerCharacter::GetWeaponSpread() void APlayerCharacter::ThrowWeaponCallback() { - FVector Location; - FVector BoxExtent; - GetActorBounds(true, Location, BoxExtent, false); - - FVector SpawnLocation = (BoxExtent.X * GetActorForwardVector()) * 2; - SpawnLocation += Location; - SpawnLocation.Z += BoxExtent.Z; - - if (TSubclassOf WeaponThrowableTemplate = GetCurrentWeapon()->GetWeaponThrowableTemplate()) + if (CurrentWeapon) { + FVector Location; + FVector BoxExtent; + GetActorBounds(true, Location, BoxExtent, false); + + FVector SpawnLocation = (BoxExtent.X * GetActorForwardVector()) * 2; + SpawnLocation += Location; + SpawnLocation.Z += BoxExtent.Z; + + TSubclassOf WeaponThrowableTemplate = CurrentWeapon->GetWeaponThrowableTemplate(); + AWeaponThrowable* Throwable = GetWorld()->SpawnActor( WeaponThrowableTemplate, SpawnLocation, FRotator::ZeroRotator); Throwable->SetWeaponSkeletalMesh(GetCurrentWeapon()->GetSkeletalMesh()); - } - RemoveCurrentWeaponFromInventory(); + RemoveCurrentWeaponFromInventory(); + } } void APlayerCharacter::ThrowExplosiveCallback()