Jump to content

**VEX NOOB** create random float values


Recommended Posts

Hi there !

I just started to do some little things in vex!

I can't understand  how to create a random integer attribute.


If i put down an attribute wrangle on some points and I type in:


f@number = rand(@numpt);


I can get some random float values.


But if i write in :


i@number = rand(@numpt);


I can just get 0 on all my points.


I think is very simple but I cannot sort it out! may be with a fit function?



Link to comment
Share on other sites

By default rand function creates a random number between 0 and 1 from a seed.

Multiply this value

i@rand_num = int(rand(@ptnum)*10);

or use fit function

i@rand_num = int(fit(rand(@ptnum), 0, 1, 0, 10));

And also in your example you used a @numpt as seed (which is return total number of points). 

Hope it's help.

Edited by MagicRej
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...