Constrain Random Clone Rotation to 90 Degree Increments

Photo of Rick Barrett

Instructor Rick Barrett

Share this video
  • Duration: 04:51
  • Views: 8964
  • Made with Release: 17
  • Works with Release: 17 and greater

Randomly rotate MoGraph clones in 90 or 45 degree increments using C4D's Formula Effector.

The Random Effector doesn't provide an easy way to restrict the possible values so you can restrict random rotation to 90 degree increments. You'll learn how to achieve this effect with the help of the Formula Effector, and the rnd() and round() functions.

Less...

Transcript

- In this Cinema 4D Quick Tip, we are going to look at how to randomly rotate something, but restrict that randomness to 90 degree increments. You might think that you'd actually go to the Random Effector for this, but there is no good way to actually contain the randomness and limit it to specific increments. So, we are instead going to use the Formula Effector. We'll go ahead and clear this one out so that we can start from scratch. I'll go ahead and add a new Formula Effector from from the MoGraph menu and again, because the Cloner was selected, it was automatically applied to the Cloner. Right here, we are going to go ahead and clear out the scale and position parameters, and we are also gonna switch the Effector tab and remove that default function. What we wanna do here is actually create randomness within the Formula Effector. We can do that using the math functions that are available in Cinema 4D. If you go ahead and open the help, and you won't be able to directly access the math functions from here, but if we search in formula, you'll find an entry called Formula Appendix. In here, you will be able to see all of the different functions that we can use within the Formula Effector. You can see that one of the functions available to us is rnd which generates a random number between zero and A, which would be whatever the first argument is. You can also provide a second argument that's used as the seed value. So, let's go ahead and type rnd. In this case, we want that value to be generated between zero and the number of possible increments minus one. The reason why is because we have zero, right? So, if we have zero and three, we'll get a total of four increments. That's what we have if we wanna break a 360 degree rotation into 90 degree increments. We'll go rnd 3. I recommend always putting in a semicolon and adding the seed value. Because, if you don't add a seed value, Cinema 4D's gonna automatically choose one and it's going to change randomly as you adjust your scene. So always provide that seed value in the random function. So now what we have is... nothing happening because we need to go into our parameter and add some rotation. You want to go ahead and set the rotation values to the increment you want to use. So we want to rotate in 90 degree increments, we are gonna set the rotation pitch and we'll do the bank as well at 90 degrees. Now you see that we are basically still getting complete randomness. That's because the output of this function includes all of the various floating point numbers between zero and three as well. What we want to do here is get whole numbers because those whole numbers are gonna multiply by the increment that we specified here in the rotation. So to do that, we'll again look at the math functions that are available. There are four that we can use. There's the Trunk function which merely truncates or lops off everything after the decimal point. There's also the round function which rounds just like you're used to from elementary school. Anything below 0.5 rounds down and above 0.5 rounds up. There's also the floor which always rounds down and the ceiling which always rounds up. In this case, we'll go ahead and use the round function. So we'll go ahead and type round and surround the rnd function with parentheses. And now you can see that we are getting this random rotation but it's restricted to 90 degree increments. If we don't like the specific randomness that's been created here, we can of course go in and change this seed and we'll get a different solution. Now the reason why I chose to use round instead of trunk or floor or ceiling, is that round is going to give me values of 0, 1, 2 or 3. If I use trunk, it would be very unlikely that I would get a value of three because the only random number between 0 and 3 that would truncate to 3 is 3.000000. And it's very unlikely to grab that. So that's why I used round here. That's basically all there is to it. If you wanted to use 45 degree increments, instead of 90 degree increments, you would just go to the parameter tab, set the increment to 45. Then in the Effector, you're gonna wanna now take into account that there are eight possible increments. And we wanna always set this value here to one less than the total number of increments because of zero. So we're gonna set this to seven. Now we have randomly rotated footballs at 45 degree increments. So now you know how to add a little randomness. But, control that randomness to specific increments.
Resume Auto-Scroll?