Announcement

Collapse
No announcement yet.

UT script, "Random?"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    To generate a random int value, use Rand(x), where x can be any positive value. The random number generated will be between 0 and (x-1).
    Note that the maximum random value generated by this function is 0xFFFF, even if you specify a much larger x.

    To generate a random float value bewteen 0.0 and 1.0, use FRand(). You have to manually "stretch" and "move" the range of values or you can use RandRange(min, max) to do it for you.

    To generate a vector of length 1 that points in a random direction, use VRand(). Multiply it with a random float value to get a random length as well.

    To generate a random rotator value, use RotRand(bRandomRoll). Leave out the bool parameter or set it to False if you want the random rotator to have a Roll value of 0.

    None of these functions require seeding and they are all static "global" functions declared in the Object class.

    Leave a comment:


  • replied
    what u mean can u give me more detail on how to use it?

    Leave a comment:


  • replied
    Well, you have RandRange(..) and FRand(), which can be used for what you want, if you're clever. No need to seed it.

    Leave a comment:


  • started a topic UT script, "Random?"

    UT script, "Random?"

    what is the command to make random var? in C we have Generator/Seedgenerator. how i do it in UT script?

    like random from 2 vars
Working...
X