- Home /
Coding Help
Hi all,
I am creating a scene where there are many pre-defined positions using empty's, and at these positions I am spawning numbers e.g. 24, 17, 5, 8, 9 to be used to equal to a sum. The player must click the numbers and add it to equal a given sum the player can choose as many numbers to equal the sum.
I know how to spawn stuff in predefined positions.
So how do I:
randomize numbers from 1-100 make it appear on screen
How do i add up which number the player has chosen by clicking e.g. sum is 42: he clicked on 24, 10 and 8 = 42#
I use and am learning in C#
Excuse me I have done my searching it is why I asked. If you are a moderator this is quite unprofessional reply. I will be contacting unity support.
I'm not a moderator, but my humble guess is:
You question title is rubbish.
Your description has little to do with the questions.
You have more than one question asked.
Hope this helps in the future.
Answer by tanoshimi · Aug 17, 2015 at 03:29 PM
For #1:
Random.Range(1,101);
http://docs.unity3d.com/ScriptReference/Random.Range.html
For #2:
int sum = 0;
foreach(number in numbersPlayerClickedOn) { sum += number; }
if(sum == 42) { Debug.Log("Player clicked on numbers that sum to 42"); }
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to move a player automatically through a List of Waypoints? 1 Answer
Adding Android Mobile Controller to Unity Project 0 Answers
Cant Make C# Use waitforseconds Command 3 Answers
Unity crash when deleting list 0 Answers