Game Development Community

Getting a random datablock

by Dave D · in Torque Game Engine · 09/26/2005 (1:32 pm) · 2 replies

I tried searching the forums for some chunk of code that will allow me to pick a random datablock. What I am trying to do is have one spawn marker for a vehicle, but have it spawn a random vehicle. Any snipplets of code that show hw to get a random datablock would be helpful.

#1
09/26/2005 (1:48 pm)
If nothing else, you could assign your vehicles datablocks to an array like id, pick a random number, and that is your vehicle.

vehicle[1] = datablock_car
vehicle[2] = datablock_truck
....
vehicle[5] = datablock_motorcycle

spawn vehicle[getRandom(5)]
#2
09/26/2005 (1:56 pm)
Hey thanks