Quantcast
Channel: Answers for "How to generate a random number inside Unity?"
Browsing latest articles
Browse All 14 View Live

Answer by Ricardo

Regarding generating a random number, you have several options:Unity's Random.Range. Do notice that it has slightly different behavior for the versions that receive floats, and those that receive...

View Article



Answer by Michael La Voie

@Ricardo gave an excellent solution, but I'd like to add one more point that is specific to game developers.Pseudo random numbers may be too random for your needs. If you are determining how much...

View Article

Answer by helmi

Thanks guys, Shuffle bag is what i'm looking for. I want to use it to my own game,I have modified some code to be used in Unity.if you wan to integrate it, here's the steps:create a javascript file...

View Article

Answer by joeyrubio

What helmi meant was this code:ShuffleBag.js var data = new Array(); var cursor=-1; function add(item, num : int) { var i = num || 1; while(i--) { data.push(item); } cursor = data.length -1; } function...

View Article

Answer by flamy

i would prefer using Random class from system, than the unity random class because it gives varitey of numbers and rarely repeating (even without seed) since it is seeded by system time by default!!...

View Article


Answer by tucano

I am working on a library to generate pseudo random numbers in Unity. May be you are interested in use it/contribute to it: http://u3d.as/content/tucanosoftware/unity-random/2Sg code is OPEN and is...

View Article

Answer by czcz1024

if use c#,can use linq like: GameObject.FindGameObjectsWithTag ("myObject").OrderBy(x => Guid.NewGuid()) to get a random sort list

View Article
Browsing latest articles
Browse All 14 View Live




Latest Images