Spawning Grenade causes ammo count to reset to default values

I don’t fully understand the intention of how your classes are structure, but if I were to guess, it appears that CurrentMagazineAmmo is a variable in your grenade class which would mean a new copy is instantiated every time a grenade is spawned and would have that class’s starting value. If CurrentMagazineAmmo were a variable within your Player or PlayerController, this would not be the case and might be more what you are intending.

On the other issues, the situation may be similar. It would appear that your grenade class is causing the Player to spawn another grenade rather than the Player or PlayerController directly handling that function.

I may be confused and this is what you are doing, but the code shown suggests the Grenade class (which is temporal for only the lifetime of the grenade) is handling functionality and variables that would normally be handled by the Player, PlayerController or some other class that stays alive and can thus manage ammo usage.

Alternatively (and I can’t imagine why it would be structured this way), if it is your intention that the grenade class handle it’s own ammo count, it would require passing the current ammo count to the newly spawned grenade so it is maintained rather than lost when the original grenade explodes.

Sorry in advance if I’m misunderstanding what you are trying to do.

2 Likes