How to get the current count of agent AssaultRifle bullets

Old Rob

New member
If enemy is killed I can pickup his ammo. This is max ammo always.
But I woud like if the Player just pickup the current count of Bullets.
Any hint how to do this?
 
If you're doing it by spawning an ItemPickup prefab, you can change the amount on the pickup:

1. Get a reference to the ItemPickup component: var itemPickup = mySpawnedObject.GetComponent<ItemPickup>()
2. Get the item definition amounts: var itemDefinitionAmounts = itemPickup.GetItemDefinitionAmounts()
3. Modify your array: itemDefinitionAmounts[0].Amount = myAmount (you would have previously saved the amount the enemy character had when it died)
4. Apply the changes: itemPickup.SetItemDefinitionAmounts(itemDefinitionAmounts)
 
Top