Ammo and reloading system

Godot Version



i currently have these variables in my gun script-

@export_range(0,1000) var max_ammo: int = 150
@export var mag_size: int = 15
var mag_count = mag_size

and a function-
func _unhandled_input(event):
if event.is_action(“shoot”):
mag_count = mag_count - 1
if mag_count == 0 or max_ammo - (mag_size/max_ammo) == 0:
can_shoot = false

it seems to carry the ammo across all guns and im not sure how to implement a reload animation

You could make an input function that only works if you have less that the full mag and have more than 0 ammo.
Hope this helps you, I might be able to provide you with an example later, as I would like to test this out before saying something wrong :sweat_smile: