Need help with Random
#1

How can I generate random coordinates like this:

Minx = 10
MinY = 2
MaxX = 20
MaxY = 4
And actually Z too but you got the idea. You have like some 3D box.
Now how do I get random coordinates in that box so I can place a random object?
I'm sorry might be easy but I suck at mathematics.
Reply
#2

pawn Код:
enum _randInfo
{
    Float: minX,
    Float: minY,
    Float: minZ,
    Float: maxX,
    Float: maxY,
    Float: maxZ
}

new randInfo[2][_randInfo] = {
{10, 2, 3, 20, 4, 6},
{20, 4, 2, 40, 5, 10}
};

new rand = random(sizeof  randInfo);
/*
randInfo[rand][minX] = ...
randInfo[rand][minY] = ....
Now you can just use these randomly generated values.
Example:
*/

new gID = GangZoneCreate(randInfo[rand][minX], randInfo[rand][minY], randInfo[rand][maxX], randInfo[rand][maxY]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)