Godot Version
4.6.1
Question
I’m making a FPS gun where the amount of ammo in the mag is displayed physically. Instead of a HUD, the bullets are shown as 3D models that appear/disappear with how much ammo is left. I have modeled this, but I am unsure how to code what I want in. I think arrays are used for this, but I’ve looked at the documentation and honestly I’m not sure, can’t seem to figure out how to use them anyway. So I’m asking here
This is my current code, obviously inefficient but shows what I’m trying to do
if magammo <= 9:
$bullet9.hide()
else:
$bullet9.show()
if magammo <= 8:
$bullet8.hide()
else:
$bullet8.show()
if magammo <= 7:
$bullet7.hide()
else:
$bullet7.show()
if magammo <= 6:
$bullet6.hide()
else:
$bullet6.show()
if magammo <= 5:
$bullet5.hide()
else:
$bullet5.show()
if magammo <= 4:
$bullet4.hide()
else:
$bullet4.show()
if magammo <= 3:
$bullet3.hide()
else:
$bullet3.show()
if magammo <= 2:
$bullet2.hide()
else:
$bullet2.show()
if magammo <= 1:
$bullet1.hide()
else:
$bullet1.show()