Hi!
I’m having trouble taking away ALL bullets from the player in my script and leave him with 1 Bullet.
The way my bullets script work so far is this:
GunScript
if (controls.Player.Fire.triggered && canShoot)
{
if (PlayerPrefs.GetInt("handGunBulletTemp") >= 1)
{
HandGunShoot();
}
}
public void HandGunShoot()
{
GameManager.Instance.minusHandGunBullet();
}
GameManager
public int handGunBullet;
public Text handGunBulletText;
public void minusHandGunBullet()//Called from GunScript
{
PlayerPrefs.SetInt("handGunBulletTemp", PlayerPrefs.GetInt("handGunBulletTemp") - 1); // Minus one bullet.
handGunBulletText.text = PlayerPrefs.GetInt("handGunBulletTemp").ToString(); //Update the text
}
Quite simple but I want to press a button and no matter how many bullets the player have, he will only be left with one bullet… Is that possible?