Join Eran Stern for an in-depth discussion in this video Random sphere animation, part of Mograph Techniques: Physics Simulations in After Effects.
- View Offline
The first step in the connected sphere animation is to create the spheres themselves, and this is what we are going to achieve in this movie. For that, I'm going to open the begin state of this composition, named connected spheres. In this composition, we only have the audio guide and I've set a marker which correspond to the audio effect that we already have in this sound.
So we will be able to easily coordinate our animation. For now, I've muted the audio in the preview panel. So we are clear to go. Let's start by creating our first sphere. Before doing so, I just want to draw your attention to this color scheme file. This is an illustrator file which I've already imported into this project, and this has the five colors that we are going to use throughout this course.
In order to keep the design consistent, I've already set up these five colors which we are going to sample from time to time. Okay, so just make sure it is highlighted over here because we do need to see the colors. Then we turn to the timeline, select it once again, hold down Alt on the PC option on the MAC and click on the grid over here in order to show the guides. I just want to start from the middle of the screen here, and I'm going to select my Ellipse tool.
Now, I'm just going to look at the Info panel to the right until I see 640 by 360. And this tells me that I'm just in the middle of the composition. Then I'm going to click, hold down, cmd on the mac or ctrl on the PC plus shift then just drag until I see this blue sphere. I'll adjust in order to verify that I have the exact color I'm going to click on the field color over here.
And using this eye dropper, I'm just going to sample this blue tint from my color scheme of course. Also, make sure that the stroke is set to nothing. If it's not the case for you just hold down Alt or Option and click the icon, it will cycle through the four modes until you see this diagonal line, which tells you that the stroke is disable. Okay, now, in the timeline, let's just rename this to sphere, and let's open up the ellipse one and under the ellipse path, under the size I just want to change it from what it is now to 30 pixels.
Now it is a little bit difficult to see what we are doing because we are seeing the boundaries of the layer as well as the shape path visibility. So first I'm going to switch this one off, and then, in order to hide After Effect's guides, I'm going to go to the View menu. And from here, you can choose Show Layer Controls and of course, just make sure it's not selected or remember the keyboard shortcut Shift+Cmd+H or Shift+Ctrl+H on the PC.
And this will show you exactly how this looks without the annoying boundaries. I'm also going to hide the grid for now, just by disabling it, and we can close this sphere. Now, my aim here is to duplicate 30 copies of this sphere. And I want each one of them to appear in a different place in terms of After Effects XYZ position. So I want After Effects to randomise the location of the spheres if you will.
In order to do so, I'm going to use a very simple expression. But I'm going to tie this expression to a null object helper which will later help us to gather all these spheres into one place which is here in the middle. So before starting with the expression, I'm going to the layer menu and from here I'm going to create the new null object. I'm going to rename this null object, position and then go to the effect menu.
And under the expression controls I'm going to add a slider control. And to this slider control I'm also going to say that the name will be position. Okay. Now I want to see the slider here in the timeline, so I'm just going to make sure that I open it all the way. We don't actually need to see the eye for the position layer just so it won't destruct us. And I also don't want to show the transform because i have a very small real estate here.
So, I'm going to press Alt+Shift or Option+Shift and just click on this which will hide it from view. Now, I'm going to select this field make sure I convert it to a 3D layer. This means that it will have x, y and z position and then I'm going to press p in order to see the position. Next I want to add an expression in order to select different values. So, I'm going to hold down ALT on the PC, option on the Mac, of course, and click on the stopwatch.
Here, I'm going to type down, wiggle, then open parentheses. The first number here should be the speed or the frequency of the wiggle. In this case, I want a very mild movement. Something which is almost zero, but not complete zero. So let's say, 0.1. Then I'm going to add the comma, and then I'm going to express the value which means how much wiggle it will give this letter by pointing it to the position slider that we've added just a moment ago.
So just select this picquic and point to the slider position and After Effects will write down all the code for you. And this means that it will take this value from this layer that we named Position, and this effect that we named Position, and of course this is the Slider. Make sure to add another closing parenthesis in order to close the expression. And then you can just click outside of it, or press on the Enter on the numeric keys.
Now nothing happens yet because in order for this wiggle to work, we need to plug some number over here. So let's change this slider value to maybe, I don't know, let's say 600 for now and we can see that this number is plugged over here to the value of the wiggle. Now we do have a very, very slight movement. And this is the reason why this ball is moving from the original location to somewhere in this case, over here at the left corner of this composition.
Now, I'm going to close the position, re-select my sphere. And go to the Edit menu and choose Duplicate. So, you can of course press Cmd+D in order to make it faster. Just want to show you where it is. And each time that we are going to duplicate another copy, and this is what I'm doing right now, I'm pressing Cmd+D. After Effects will take the wiggle values and change them according to the index number of the layer itself.
The index number is this number that you see over here. So this means that every time that we are creating another duplicate And I'm going to stop at 29 because I already have the first one. Each time we are doing this we have a different kind of values which are being plugged into the wiggle expression. Let's press zero now, and we can see that we got exactly what we are after. Very simple method to create a lot of rotating or moving spheres around the screen and everything is still live and connected to this null object.
So if you want to spread them across, you can basically just change the value over here. Or if you want the other direction you can reduce it to whatever makes you comfortable. I'm going to stick with 600 and once again I'm going to create a quick run preview in order to check the animation. It does look very promising at this stage, but before applying the Connect Layers script, I think that we can work on it a little bit and improve it.
So in the next movie, I'm going to show you how to create a nice cascade animation. And also scale these spheres so each one will be appearing in a different kind of way. And not it's just be there from the beginning to the end.
These lessons are perfect for motion graphics artists who want to create earthy physics simulations and add realistic motion to their projects.
- Building a random sphere animation
- Creating a tree connection
- Animating letters dangling from rope
- Creating body types and groups
- Staggering layer simulation