From the course: Learning Cinema 4D Lite for After Effects

Creating a wiggle expression

From the course: Learning Cinema 4D Lite for After Effects

Start my 1-month free trial

Creating a wiggle expression

Anyone who's used After Effects will have undoubtedly used the wiggle expression in After Effects, which is useful in so many ways. I'm going to show you how you can create a similar expression in Cinema 4D. It's quite a different interface and a different way of applying it, but the same logic really applies. We're in chapter 7:01, if you want to follow along. You can open up that project. And in here we have a random factor object which is applying this kind of random animation. And in here, what I've done is in the parameters I've had it apply the animation to both the color, position, scale and also rotation, I think. Yeah, little bit of rotation as well. So you'll see that when I adjust the strength, okay, it adjusts the strength of the, the position, scale and rotation nicely. But if I go into Fall Off and adjust the weight, it also adjusts the color. So were getting some addition animation by stripping that weight value. So what I want to do is I want to get something controlling this so that it's animating over time. I don't want to have to key frame it individually. So what we're going to do is take that weight value and add an expression to it. So the weight value is part of the random factor object so that's what we're going to add the expression to. And the first thing that we need to do is go into our tags, Cinema 4D tags and add an XPresso tag, and that allows us to start using XPresso to write scripts. Now, it brings up the XPresso Editor, which may seem a little bit scary, but don't worry too much about it. All we're going to do, is first of all, create a couple of nodes. And this is how XPresso works, it works by connecting nodes together, so in After Effects you would write lines of code or text separated by full stops. If you just think of these nodes as individual elements and it saves you having to type them out. It's a much more visual way. Of writing expressions, so first thing we need to do is create a node for our object. So we right click on here, new node XPresso, general and we are just going to say object and that's going to add an object with the word random on it. Now what we can do is we can say okay, I want a new input. You've got input and output from these nodes. And we want to input a value that will randomize into our random object. So I've got to click on here, and we'll go to look at the properties that we could add that value to. And you can see all the properties that are associated with that random effect or object are listed here. If we go into our effector, we have the strength value I showed you earlier. If we go into fall off We have weight, so this is the property that I want to adjust. So I'm going to choose weight. So random weight is what we're going to feed values into. We now need to decide what will generate those values. And to do that we need to create another note. So, here I'm going to go to new node >espresso> general again. Now I want to use, get a random kind of value. And a good way of creating randomness is to use noise. So I'm going to click general, noise. And that's adding noise, okay? At the moment, it has an output button and this is an input button. But at the moment, we're not getting anything happening but watch what happens. If I click and drag, and think of this like the pick whip in After Effects, I drag it to the property that I want to adjust. When I let go, it connects them together and, immediately, you could see some animation happening there. Now, if I Preview that. Let's just preview a little section. You'll see we are getting a little bit of animation happening. Now, really, it's not enough. So I want to see what. The value that's being generated by this is so i am going to right click on here again seeing new node, expressive, general and this time I am going to say I want to see the result and if I click another pick whip kind of thing from here to here it will tell me what the result is. And if I scrub through I should be able to see that value updating. So we can see the range of results we're getting as we scrub through. Now I may decide I want to multiply this maybe by a value so if I want to I can add another node. This time I'm going to add a calculate node. Because we want to do some maths, on the value that's coming out of the noise. So, I go to math, so Calculate > Math. And that gives me an input, and an output. Now at the moment, it's an add operator, and if we have a look down here, you'll see, under function, it has add. So when I select each of these, you'll notice that the Attributes Manager is updating to show me context-sensitive information. So if I select Add, I could change that to Multiply. So I could take the noise, put it in between here. And here. So instead of just going directly from here to here, it's being rerouted through here. Now at the moment, you'll notice that that value hasn't changed. If I just undo that, okay, and undo again, so it's 0.21, if I reroute it, it's still 0.21. >> So, how do I get it to multiply? Well, if I select the Multiply Node, you'll notice down here I have some inputs. And input 2. So, I've got the noises input 1. Input 2 will be the amount that I'm going to animate it by, or multiply it by. And you'll notice that as i increase that value. I'm getting more animation. And I can go up to a value of four before it stops really having the result. Now, at the moment you'll notice the result hasn't changed. And of course that's because the pikwip or the link is coming from the noise. So before this is happened. So we really need to pull the output down to the result now. Instead and you will see that as I adjust the second value the result value changes. so its quite kind of easy to figure out once you've get your head around the nodes and what you create nodes for, so you want the object and the property that you to want to effect . You want the thing that you want to create to affect that and then you have basic mathematical functions that will allow you to adjust that. And then of course you can view result by using the result box. So that's a little bit about how to create your own wiggle animation in Cinema 4D. Let's jump back to the beginning and just preview that. Now obviously we may want to make that a little faster and we'll see how we can customize it in later tutorials.

Contents