Beginner trying to set up random variable for game + and then some.
HIya!
For a school project I need to make a game that has three factors a kid can check. Temperature (too hot, too cold, just right), chlorine (stanky, toxic, just right) and levels (too much water, too little, just right).
I want the game to start with some random units for these. Say -1 is too hot, 1 is too cold and 0 is just right.
Then I want a script that kind of.. checks that?
So when the kid tests their water, the script essentially says:
If water is CORRECT, move onto checking next variable (chlorine), if chlorine IS NOT CORRECT, SPAWN the background image of it being toxic etc.
Does anyone know the right way to start about this? I can link my game assets I have so you can get a better idea, as well as a paper prototype so you can see where I want this game to go.
I am an ABSOLUTE beginner so I apologize!
for the random stuff you can use the below code.. int rand = Random.Range(-1,2). // in unity the upper bound is exclusive this will give you a random integer between -1,0 & 1
and then you can use the above nested in another if code to see if it is correct then check the next parameter if not then display the pic
Hey thank you! I found out about the random range code. Could you link me to an example of what code I'd need for checking parameters and if false displaying the pic. Would it be working with bools? Or 'if' statements or am I way off (also pretty likely)?
Would I put the random range code into an empty game object named what I'm trying to check? EG chlorine? Or would I just have one big script for my whole game that goes "Check chlorine, if -1 go to this background." as well as letting a player -1 or +1 to chlorine?
Answer by adiict0 · May 06, 2017 at 10:02 PM
Good luck with this bud. I dont know how to do all of that but it looks like a nice proyect! Keep it up :)
Answer by krishnalomeli · Dec 10, 2017 at 11:50 AM
ones i was having difficulties with variables i found a place where it is described in the clearest and childish way - see here - https://codeasy.net/lesson/variables_and_int_type_introduction