Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink
Go down
Member [Lv. 0]
Member [Lv. 0]
Posts : 1
Points : 1068
Rep : 0
Join date : 2015-08-17
View user profile

Spawning random numbers on predefined positions

on Mon Aug 17, 2015 8:03 pm
Hi all,

I am in a kaffuffle...

I want to spawn random numbers say between 1-99 to display on the screen in predefined positions. So:
The code spawns either of the two prefabs on predefined positions using emptys.


        [SerializeField] GameObject PrefabA;
 [SerializeField] GameObject PrefabB;
 [SerializeField] Transform[] spawnPoints = new Transform[8];

for (int i = 0; i < spawnPoints.Length; i++) {
 Instantiate((Random.Range(0,2) == 0 ? PrefabA : PrefabB), spawnPoints[i].position, Quaternion.identity);

So how do i convert this to spawn random numbers ranging from 1-99... When the numbers are clicked it will add up and match the sum of 42?
Member [Lv. 3]
Member [Lv. 3]
Posts : 25
Points : 1751
Rep : 7
Join date : 2013-12-14
View user profile

Re: Spawning random numbers on predefined positions

on Tue Sep 08, 2015 1:14 am
Well from what i can tell in Word format....

search for object with tag..
set a array for object in pool.
10 objects in pool... there are empty game objects
set a bool for each... this will let it know if its been clicked or not
set it to only accept 2 TRUE bool values
+ those 2 bool clicked values as true as it will contain already random numbers 

try to stay with one set and i think FLOAT is what random.range uses without formatting to INT..
Back to top
Permissions in this forum:
You cannot reply to topics in this forum