Random of two possible choices always spawns in the same position

Hi all. I’m making an educational healthcare game where you have to shoot the parachuted care package corresponding to what type of assistance it is (see screenshot). For example, if the ribbon says ‘Research cancer treatments’, you must shoot the (first) parachute on the left that says "Informational’. If the ribbon says ‘Buy groceries for patient’, you must shoot the second parachute on the right that says ‘practical’. Only two parachutes ever spawn at a time. Once you shoot the correct parachute, it resets the loop and continues spawning more sets of two parachutes until you shoot the number of parachutes needed to win. The code to pick a random string (i.e. the two possibilities to display on the parachutes works just fine.

However, I noticed the correct answer to shoot is always the parachute on the left, without fail. So I only have to rotate the cannon to that fixed angle and keep pressing Fire in order to win, which as you can imagine isn’t very challenging. Can someone help me randomize it so that the correct parachute to shoot alternates between the left and right? There is only one spawnpoint: a game object named ParachuteSpawnPosition which is attached to the lerping helicopter, and it is from this game object the parachutes spawn from, using an spawn interval. Here is the relevant code.

Thank you for any help in advance!

UPDATE: I ended up just randomizing the spawn interval and that seemed to suffice

Your solution seems a bit overly complex and I’m having a hard time figuring out what’s going on here.

You’ve said that the text on each crate is randomly switching sides like you want, but the correct crate to shoot is always on the left. So when you’re checking if the crate the player has shot is correct or not, it must be independant from the text that’s displayed?

Where is the code that determins what a correct hit is? There’s nothing here that seems to flag a specific Parachute as being correct or not.

1 Like