Page 1 of 1

Random Numbers

Posted: Sat Jul 27, 2013 10:17 am
by DeltaJuliet
HI,

Just starting to have a play with the graph editor.
i want to create 2 random numbers, so i made 4 constant/real nodes, 2 minimum value 2 maximum value
i cant find a way to take each pair (min/max) and output a random number within the min/max range.

how can this be done?

cheers.

Dave.

Re: Random Numbers

Posted: Sun Jul 28, 2013 8:09 am
by CG_Nema
It goes like this. Lets say you want a rand from 2-6:

type 2+rnd(4) (The sum of 2 and a random number between 0 and 4)

Hope that helps.

Re: Random Numbers

Posted: Sun Jul 28, 2013 8:55 am
by DeltaJuliet
Hey CG_Nema,

To be honest that doesn't help :D

I needed to know the correct node's to use in the graph editor and have since found (i think) the one i need - "ArrayNumRandom"
Image

that outputs two sets of random numbers, i just need to know how to plug these values into a null's x and y position now :D

Replies are like gold dust on this forum, so thankyou for yours 8-)

Dave.

Re: Random Numbers

Posted: Sun Jul 28, 2013 9:06 am
by CG_Nema
Got it sorry I thought you were doing it with the curve editor, I skimmed through your post a little too quickly :P.

I would recommend you do it the way I explained with the curve editor, the only reason you should do it with graphs instead would be if you want the node's value to change per-step because the rnd() expression in the curve editor will only choose and new rand per frame.

If you want it to change per-step then go ahead and do it with the graph like this:

Use the "SetNodeParameter" graph node.
Plug in the the node and connect the random number to the "number value" input.
And for the parameter, when its a vector parameter, like a position, you can type "position.x", "position.y", or "position.z".

This should be more helpful than my previous post :D.

Edit:

Scratch that, I don't think it's going to work because the "seed" on the random number array is always the same so the random number it spits out is always the same. Maybe I did something wrong there, but if you can get a different random number every time you run the graph than the "SetNodeParamter" node should still work for you.

Re: Random Numbers

Posted: Sun Jul 28, 2013 9:17 am
by DeltaJuliet
No worries :D

I am only doing it this way to get some experience of the graph editor, and i do want this to change per frame so i will go with the curve editor method for now.

cheers.

Dave.

Re: Random Numbers

Posted: Tue Oct 25, 2016 9:16 pm
by rebusbakery@gmail.com
DeltaJuliet wrote: that outputs two sets of random numbers, i just need to know how to plug these values into a null's x and y position now :D
These are the graph nodes you might be interested in:
*Conversion/Vector3FromComponents
*Scene Node/GetObject
Scene Node/GetTransformation
*Scene Node/SetTransformationFromComponents
Math/Add


the * ones will get you exactly where you want to be 'now': GetObject to fetch the null, Vector3From... to create a vector from your random numbers, SetTransform... to set the position vector of your null. You should be able to figure out the connections needed. Using the other nodes you could move the object relatively instead of absolutely.