Random Numbers

Post Reply
DeltaJuliet
Posts: 78
Joined: Thu May 30, 2013 1:19 pm

Random Numbers

Post by DeltaJuliet » Sat Jul 27, 2013 10:17 am

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.

CG_Nema
Posts: 67
Joined: Fri May 31, 2013 5:23 am

Re: Random Numbers

Post by CG_Nema » Sun Jul 28, 2013 8:09 am

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.

DeltaJuliet
Posts: 78
Joined: Thu May 30, 2013 1:19 pm

Re: Random Numbers

Post by DeltaJuliet » Sun Jul 28, 2013 8:55 am

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.

CG_Nema
Posts: 67
Joined: Fri May 31, 2013 5:23 am

Re: Random Numbers

Post by CG_Nema » Sun Jul 28, 2013 9:06 am

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.

DeltaJuliet
Posts: 78
Joined: Thu May 30, 2013 1:19 pm

Re: Random Numbers

Post by DeltaJuliet » Sun Jul 28, 2013 9:17 am

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.

rebusbakery@gmail.com
Posts: 32
Joined: Thu Jan 05, 2012 11:49 pm

Re: Random Numbers

Post by rebusbakery@gmail.com » Tue Oct 25, 2016 9:16 pm

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.

Post Reply