butler 0 Report post Posted April 24, 2012 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! Quote Share this post Link to post Share on other sites
C.Smith 0 Report post Posted April 25, 2012 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. Quote Share this post Link to post Share on other sites
butler 0 Report post Posted April 25, 2012 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! Quote Share this post Link to post Share on other sites
Zickar 0 Report post Posted April 29, 2012 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 Quote Share this post Link to post Share on other sites
C.Smith 0 Report post Posted April 29, 2012 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) Quote Share this post Link to post Share on other sites
TimC 0 Report post Posted May 10, 2012 If you want to do it with Xpresso then you could use a monoflop node to only execute the nodes once. Alternatively you could use a boolean and then uncheck it each time. See Fake Button here for an example of this http://zabiegly.de/xpresso/index.html cheers Tim Quote Share this post Link to post Share on other sites