Jump to content
Sign in to follow this  
butler

Random Position using C4D Xpresso

Recommended Posts

Hey guys, I'm looking make an spline/object go to a random position in the x and y axis using xpresso.

So the setup is I have a user data of a integer for my random seed and then just a boolean that when it is checked it just go to a random position between like (-100 to 100 in the x and y) based on the seed.

Pretty sure this is possible but I'm not sure how to come up with the random position.

I'm guessing it is just a node that I have never used. Anyways hopefully this is pretty simple for someone to answer for me. Thanks!

Share this post


Link to post
Share on other sites

Do you want it to change per frame? or just once?

 

If it's once you should just make a quick python script that will perform the action each time the button is pressed.

 

And if you want it once per frame do you want it jittery or smooth?

 

If you want it smooth, you can use the Vibrate Tag or my CS_Vibrate. If you want it completely random, I would just use the random functions in Python in a Python tag. That will be way quicker and easier than Xpresso I think. You can look up the random functions in python by just typing Python and random and you should see the Python docs on random.

Share this post


Link to post
Share on other sites

Do you want it to change per frame? or just once?

 

If it's once you should just make a quick python script that will perform the action each time the button is pressed.

 

And if you want it once per frame do you want it jittery or smooth?

 

If you want it smooth, you can use the Vibrate Tag or my CS_Vibrate. If you want it completely random, I would just use the random functions in Python in a Python tag. That will be way quicker and easier than Xpresso I think. You can look up the random functions in python by just typing Python and random and you should see the Python docs on random.

 

 

I was looking to have it just change once. I'll do some searching for a python script and hopefully find something. Thanks!

Share this post


Link to post
Share on other sites

There is a random node in Xpresso>General>Random , you can output different types like integer , real and vectors from it but the problem is that it keeps changing with time , I think the best option for you is to create a user data and input this into a formula node in Xpresso , use the formula node to create a random output for you and then input this back into the position using a range mapper to map it between two values

Share this post


Link to post
Share on other sites

 

 

I was looking to have it just change once. I'll do some searching for a python script and hopefully find something. Thanks!

 

Xpresso is always an expression that is called every cycle. Again if you do a python script, it happens once per button press which is what you want.

Here is the elegant and simple 'random' function in Python:

random.random()

Return the next random floating point number in the range [0.0, 1.0)

Share this post


Link to post
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.

Guest
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.

Sign in to follow this  

×
×
  • Create New...