I’m making a revolutionary war project, and the muskets back then jammed. So I can get the gun to jam with this bit of code:
if(bulletShotCount == 30 || spitfireShotCount == 7){
canShoot = false;
}
bulletShotCount
is a variable that increases by one every single time the shot is fired. So when the shot count equals 30, the gun “jams”, and the player can no longer shoot. But I want it to jam randomly, as if to say, it can jam at 10, or at 7, or at 1, or at 2. So what I though I would do is make to variables:
var bulletGunJam = int[];
var spitfireGunJam = int[];
So I figured that if I made those two variables arrays, that it would choose one of the values in the array, and pick one randomly each time. It obviously didn’t do that. Here’s the code I used:
if(bulletShotCount == bulletGunJam || spitfireShotCount == spitfireGunJam){
canShoot = false;
}
Is there another way to make it jam randomly?