#Random query?

1 messages · Page 1 of 1 (latest)

sleek flicker
#

I remember there being a random query or thing I could use to randomize whether the query would return true but I'm not finding it in the documentation. Does anyone know what it is? it plugs in where a query would normally go in the animation controller and returns 0 or 1 randomly

willow wing
#

math.random, math.random_integer

#

both take 2 variables, a min and max. It returns a random value between those two

sleek flicker
#

{ "test": "math.random_integer(0,5)=5"}?

willow wing
#

no: "test": "math.random(1, 4) == 3"

#

= is an operation that sets a variable, == is a comparator that checks if 2 values are equal

sleek flicker
#

my bad. Thank you!

willow wing
#

You'll need to define a variable prior to entering the state and check if that variable is equal to a value (you will need an escape state to make sure that it doesnt just transition to the check, then stay there until you reglog)

#

to define a variable, you can just do this

{
  "check_rnd": "v.rand_int = math.random_integer(1,4); return query.is_jumping;"
}
sleek flicker
#

Does that go in the states as its own state?

willow wing
#

Ohh wait nvm

sleek flicker
#

where do I paste the variable in the animation controler?

willow wing
#

The variable goes before your transition query

#

So the state before you are checking against the random value

sleek flicker
#

that makes sense. So it gets defined randomly each time that state gets entered?

#

If you have a sample file that uses it I would appreciate seeing it in context, although you've already helped a ton. I should be able to work from documentation now

#

Thanks again!