diff --git a/Source/Nakatomi/NakatomiCharacter.cpp b/Source/Nakatomi/NakatomiCharacter.cpp index beb01fa..269b84b 100644 --- a/Source/Nakatomi/NakatomiCharacter.cpp +++ b/Source/Nakatomi/NakatomiCharacter.cpp @@ -154,6 +154,19 @@ void ANakatomiCharacter::AddWeaponToInventory(TSubclassOf weapon) } } +void ANakatomiCharacter::AddWeaponToInventory(AWeapon* weapon) +{ + weapon->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetNotIncludingScale, "WeaponHand"); + weapon->SetActorEnableCollision(false); + weapon->SetActorHiddenInGame(true); + WeaponInventory.Add(weapon); + + if (WeaponInventory.Num() == 1) + { + SetCurrentWeapon(WeaponInventory[0]); + } +} + AWeapon* ANakatomiCharacter::InitializeWeapon(TSubclassOf weapon) { FActorSpawnParameters SpawnParameters; @@ -188,4 +201,9 @@ void ANakatomiCharacter::SetCurrentWeapon(AWeapon* weapon) CurrentWeapon = weapon; CurrentWeapon->SetActorHiddenInGame(false); } -} \ No newline at end of file +} + +int ANakatomiCharacter::GetCurrentInventorySlot() +{ + return CurrentInventorySlot; +} diff --git a/Source/Nakatomi/NakatomiCharacter.h b/Source/Nakatomi/NakatomiCharacter.h index 4294ecf..36cbeec 100644 --- a/Source/Nakatomi/NakatomiCharacter.h +++ b/Source/Nakatomi/NakatomiCharacter.h @@ -63,6 +63,8 @@ public: void AddWeaponToInventory(TSubclassOf weapon); + void AddWeaponToInventory(AWeapon* weapon); + void RemoveWeaponFromInventory(int i); void RemoveWeaponFromInventory(AWeapon* weapon); @@ -74,4 +76,6 @@ public: AWeapon* GetCurrentWeapon(); void SetCurrentWeapon(AWeapon* weapon); + + int GetCurrentInventorySlot(); };