Game Development Community

getRandom always returns same values on ipad hardware?

by Randy Condon · in iTorque 2D · 10/31/2011 (12:37 pm) · 8 replies

Has anyone had this problem?

I have a group of objects that call getRandom within their onLevelLoaded function.

When I run on the simulator, everything is as expected.

When I deploy and run on the iPad2 hardware, iOS 5, iTorque 1.5, xCode 4.2, I get the same values for all the objects.

System.cs calls setRandomSeed();

So to summarize, everytime getRandom(0,3) is called, it returns 3. But only on iPad 2 hardware, not the sim.

Thanks

#1
11/03/2011 (4:00 pm)
So to fix this I created my own random function using arc4Random()

That worked for me.
#2
11/05/2011 (9:45 pm)
I use getrandom all the time on iPad 1 and it doesn't appear to have this problem.
#3
11/05/2011 (10:45 pm)
Same here, I haven't had to use it a lot yet, but:

$totalSpinsReel1 = getRandom(4,$totalTilesPerReel /4);

is working like a champ for each of my 5 reels in my slot machine project on an iPad 1.
#4
11/07/2011 (2:14 pm)
Are you guys running ios 5? Thanks for the replies, too.
#5
11/07/2011 (6:15 pm)
iOS 5 here on my iPad 1.
#6
11/08/2011 (2:21 am)
I'm using getRandom() a lot and never had any issues, both on the device(ipad 1 iOS 4.3, ipad 2 iOS 4.3 and 5) and on the simulator.
I'm using iTorque 1.5
#7
11/08/2011 (10:47 am)
Hmm, weird. I did download the latest, greatest XCode, but I don't know why that would cause any issues.

I worked around it by doing this, just in case anyone else runs into this problem.

#8
11/09/2011 (12:55 am)
Does the problem also occur when you remove the setRandomSeed() call?