Here is the code to use if you require Weighted Randoms.
var fruits=["Apples", "Oranges", "Grapes", "Bananas"];
var fruitweight : Array =[2, 3, 1, 4]; //weight of each element above
var totalweight=eval(fruitweight.join("+")); //get total weight (in this case, 10)
var weighedfruits=new Array(); //new array to hold "weighted" fruits
var currentfruit=0;
while (currentfruit
for (i=0; i
weighedfruits[weighedfruits.length]=fruits[currentfruit];
currentfruit++;
}
var randomnumber=Mathf.Floor(Random.value*totalweight);
Debug.Log(weighedfruits[randomnumber]);
Posted in: Unity3d.


You can even have a go here GoGoTunnelRunner
Enjoy
Posted in: Unity Games, Unity3d, iPad, iPhone.
Want to know how your iOS game is performing ?
iPhone/iPad Unity internal profiler stats:
cpu-player> min: 9.8 max: 24.0 avg: 16.3
cpu-ogles-drv> min: 1.8 max: 8.2 avg: 4.3
cpu-waits-gpu> min: 0.8 max: 1.2 avg: 0.9
cpu-present> min: 1.2 max: 3.9 avg: 1.6
frametime> min: 31.9 max: 37.8 avg: 34.1
draw-call #> min: 4 max: 9 avg: 6 | batched: 10
tris #> min: 3590 max: 4561 avg: 3871 | batched: 3572
verts #> min: 1940 max: 2487 avg: 2104 | batched: 1900
player-detail> physx: 1.2 animation: 1.2 culling: 0.5 skinning: 0.0 batching: 0.2 render: 12.0 fixed-update-count: 1 .. 2
mono-scripts> update: 0.5 fixedUpdate: 0.0 coroutines: 0.0
mono-memory> used heap: 233472 allocated heap: 548864 max number of collections: 1 collection total duration: 5.7
You can now with the built in performance profiler see here for details http://unity3d.com/support/documentation/Manual/iphone-InternalProfiler.html
Posted in: Unity3d.
Tagged: iOS · ipad · iphone · unity3d