Russian Roulette Loop

Hello Guys, thanks to everyone who has taken their time reading this problem or even viewing it. I currently encountered a problem in which I was seeking help. I was building a Russian roulette type of game but I was trying to use a loop within the code. I have commented on what I wanted to code in my script. Below is a snapshot of the script.

    private void Start()
    {
        //on start make the bullet position to 1 default and later on update to the random bullet when the game is over
       
    }
    private void RandomBullet()
    {
        //if the game is over random generate the bullet position (use a bool to detect)
        //if the game starts random generate the bullet position (on click restart/ use a bool)
       
    }

the loop should be able to start from 1 to 6 and can also restart again when game is over or when restating the game

I cant seem to find a question.

You want to do something russion roulette related. Great.
You encountered a problem. Alright, what problem?
You want to use a loop… ok… what for, what is your problem?
You wrote comments into your code. Alright, but what is the question?

1 Like

How do you make a loop which can restart? what I mean is for example when the bullet on start is at 1 so when the game is over the bullet position to be randomly changed to another position using a random.range(1,6) or increment by 1…but the loop should only range from 1 to 6 and can also restart again to 1 or within the range of 1 to 6 and not get past 6.
The problem which I had was getting my bullet position to randomly position at every start of the game or when the game is over…I have the idea but I don’t know the way forward and how to implement it.
I don’t know if this helps!

I wouldnt use a loop at all.
Generate some number 0-5. When the user pulls the trigger, if the number is 0 he dies. Decrement the number.
Repeat until … the user dies?

Rinse and repeat, as in generate a new number and that’s it pretty much.
The rest is animations and user input. Unless im misunderstanding what you are actually trying to achieve.

Do you need anything more than that?

1 Like

it worked thank you so much…

1 Like