Can You Roll A Ball in Blender?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome back to another default cube cg matter tutorial and today I want to talk about how to make this rolling ball animation which kind of seems like it's obvious you just take a sphere you animate the location with keyframes animate the rotation but you're gonna notice that this rotation actually makes physical sense like the rotation follows the direction of the path and that's kind of not an obvious thing to do so today we're going to be talking about how to make this using an arbitrary path so you can see I actually have this defined as a curve and we're also gonna talk a bit about the shading so you see that this actually has some stripes on it so we can actually tell the orientation of the sphere which matters if this thing is rotating so we're gonna be using curves we're gonna be using um we're gonna be using the graph editor which is probably not something used quite too often and yeah I guess I guess I guess now you're excited so let's get started I'm gonna start off with a brand new scene assuming you haven't messed with your blender this is what your default scene looks like as well so once you're here we're gonna delete the cube we're gonna add in a sphere now technically this technique works with any object but since we're talking about a rolling thing you probably want the sphere since it can change direction or you could do a cylinder but it's not going to be able to change directions in every way because it's not symmetric but whatever you have a sphere we're gonna do shade smooth fine you can also subdivide it a bit more if you care I don't and the first thing we want to do is specify the path that it's going down so what we don't want to do is add a keyframe here go to a different frame animate keyframe and then play that we don't want that we want a fully procedural approach that gives us a lot more control and that we can edit much faster so what we're gonna do is we're gonna shift a to add a curve and you can pick any of these curves this is just us defining a path but if you want one that isn't or do you like pre-made I recommend you do a Bezier this is a nice word and you can see it over here it starts off very small I don't know why it spawns and so small but you can take this curve tab for edit mode and then scale everything up and you want to do the scaling in edit mode as opposed to object mode and I don't know if it matters for this both other stuff it can cause them which is if he don't so make sure you're in edit mode and if you want to edit the path you can of course just select a vertex and move it on the XYZ axis whatever or you can hit e to extrude and that's just gonna add more to our path so I'm just gonna I don't know put this somewhere here I don't want to go along the z-axis since I want this all to be coplanar so it's all on the ground plane and once you have your path defined it can be any length any amount of wine deenis we're also gonna make it a bit higher resolution because you can see these segments are kind of very they're very sharp corners and we want this to look more like a smooth path so to fix this we're gonna go to the curve properties what's this called is it called object data yeah object data properties Icom curve properties and for the preview we're gonna take our resolution preview and bump that up and you can see now we have something much smoother so this is before and then this is after it did not update let's try it again this is after there we go maybe that's a bug okay cool so now we have our path defined and we're back in object mode and to have our sphere go along it what we're gonna do is we're gonna select our sphere and then you might think that you need a modifier for this but it's not a modifier it's actually a constraint because we're constraining it in terms of location and orientation so go to constraints over here and then go to follow path because we're gonna have the sphere follow a path so for our target being what path do we want we're just going to choose our Bezier curve because we didn't rename it and it's gonna start off at one endpoint this can be thought of as either the start or the end depending on your perspective and to animate this going along the path you're gonna look at this offset and the first thing you're gonna try is making it positive and it doesn't do anything so your next step is to make it negative and you see that it's actually sweeping across in a linear fashion meaning that when we're at zero it's on one end when we're at negative 100 as in a hundred percent negative 100 it's at the other and if we go to something like a negative 50 it should be halfway in between in terms of length so this wine deenis section is just as is that section so that is the halfway point which means we can go 2-0 add a keyframe by hovering over hitting I or you could just right click and add a keyframe that way but we have a keyframe go to frame let's limit this to 100 so on frame 100 I'm gonna have it go to again negative 100 you can think of this as a hundred percent completion of the path add another keyframe and when we play the CC it's sweeping along but if you're looking carefully the interpolation is a bit weird right it starts off at zero velocity and speeds up it accelerates hits max velocity over here and then slows down and that's because the interpolation is set to Bezier as well I think yeah this is interpolation so we can change interpolation by either I think there's a menu inside graph editor to do it but what I recommend is the hotkey is T so T as in tiger I don't a hit T change the keyframe interpolation to linear that way it's going to be at constant velocity or I guess velocity is changing because Direction is changing but constant speed is probably the physicists will correct me if that's an issue okay cool so now the next issue now that we have this going along our path is the orientation we want it to roll and to actually make sense but even if we do that kind of stuff you're not going to see it because it's a sphere and it kind of looks the same everywhere so the stuff we need to do before that is actually give this a bit of shading so we can actually tell which side is up etc so once you have your sphere selected we're gonna go to shading and then we're gonna create a new material and you have a bunch of options for this you can either add an image texture or use a procedural one I'm gonna be using a procedural one and we can keep this be SDF and just you know tag along anything you could do something like a noise texture it really doesn't matter so here's a noise texture so this is what this would look like you can tell this has orientation right so if this was rolling you could tell that this pink swatch would be in one area not another so I think for the demo we did stripes let's just do this it's fine so noise texture we want to up the contrast so I'm just going to add a brightness trust and maybe this will make there we go it doesn't look good kind of looks a good job breaker actually it doesn't look good but it's gonna be useful to see if we know what's going on so back in the layout workspace we can't see it because we need to be in either look dev or rendered mode in this case they're both easy so it doesn't matter and you can see that this is kind of just sweeping along without rolling and also without changing orientation it's not changing which direction it's facing and the first thing we can do is fix that so when it's here we want it to be facing along the path when it's here it will be facing that way when it's here it will be facing that way etc and to do that all you have to do is hit this very convenient button which is follow curve and you can see it says the object will follow the heading and banking of the curve which is exactly what you want so follow curve and now you can see it's actually always pointing in the direction of the path so I want you to notice that where this you know hits the path you have this kind of texture right here and over here you have the exact same patch of texture so it's actually moving with it which means now if we roll it it's always going to be going in the same direction so that's the next step and now the question is okay how do you actually animate or keyframe the rolling doesn't it change orientation all the time so when you need a roll on the X and then X and y at the same time and whatever well the the reason that this isn't an issue is because of this follow curve and our rotation is going to be relative to the object's coordinate system okay what do I mean by this what I mean is let's say we animate the X rotation which right now seems like the right one right it'd be rolling in this orientation to go along the path whereas something like whoops whereas something like Y doesn't really make sense for rolling nor does I don't know why keeps going there or nor does Z so what we're gonna do instead set this to zero is we're gonna animate this but just like last time we didn't want to animate location we don't want to do this manually so if we did something like keyframes 0 go to frame 100 then keyframe I don't know two full revolutions it's probably not much but to do 720 and then add a keyframe and then you know you could also set it to linear in all this you can see that you know the idea is right I think it's actually going in the wrong orientation so let's do negative 720 and then key frame same idea so you can see that the idea is right but it's definitely not rotating enough it's like moving faster than it's rotating and even though this is a solution that works they're gonna have to keep changing the number and keep replacing the keyframes which takes a lot of time so we want a better option that actually works a lot better for this so let's do it our keyframes or clear our keyframes rather so again we just have this orientation thing but not the rotation so what we're gonna do what we're gonna do is we are gonna add a keyframe just for the first one for the X rotation in this case or just click I but then we're not going to do what we did before instead what we're gonna do is we're gonna go to the graph editor and you can see right now we have our sphere selected so we have a bunch of sphere properties if we deselect it it's not going to be there so select the sphere and inside our object transforms which is only going to include rotation because that's the only thing that's key frames we can select our X rotation since that's what we care about and then right now it's a flat line because we haven't animated it it's just at 0 what we can do is hit n to get these to get this panel right same thing up here you hit on here you hit N and what we're going to do is we're going to go to modifiers and we're gonna add in a I think there's a couple ways to do this but the way I like to do it is generator and basically this is a way to create a polynomial but if it's a polynomial of order one and I'll explain what all this means soon if it's a polynomial of order 1 this number right here this one is just saying what speed do we want our rotation so if we hit play you see it's rotating it's rotating very fast so what we can do is make this number small or something like point one where zero is no rotation so point one is closer to no rotation so point one is slower but it's in the wrong direction it's a revolving backward so what do you do you make it negative negative 0.1 and now we play it and you can see this is much faster than keyframing keyframing it manually because we can control it just with one number so now we want the same thing but maybe rolling a bit faster maybe twice as fast so negative point two and then you just kind of want to figure out what number is perfect for this of course there's a mathematically perfect way of doing this but you know you could just eyeball it so negative point two seems pretty correct to me and the reason this whole polynomial thing is useful is right now we're rate where I'm creating an expression that will dictate what number is sent to this rotation this polynomial order 1 is basically just saying over time this is going to be our slope negative point 2 which in this case is correct because of orientation this is going to have a constant slope in other words it's gonna have a constant change of rotation right so if you look at the graph which we need to make it a lot bigger to actually see because it's very slanted this red line is our rotation and you can see it has a constant slope which means that over time this rotation is changing by the same amount and it's downwards because that's the correct orientation if we did point two it's gonna point upwards by the same magnitude of slope but in this case we want downwards so that's just kind of the theory behind there but then the question is okay so we can edit the speed and the orientation and all this on the fly can we also edit the path and everything works and yes you can that's why this is a great technique so select your curve edit mode we could either like extrude to add a bit more to this or you could I think loop cut I don't really know how this works can you like subdivide yeah you can subdivide to add more control points so I'm just gonna take a new control point and move it over here and remember we animated the location not you know we didn't like bake it in but what we said is we baked in progression so we started at zero and then went to a hundred percent completion so no matter what path we do it's still going to go from the beginning to the end in a hundred frames in this case so you can see the rolling still works and during and everything works however of course if we make this path very long so by stretching it here this path has become very long you're gonna notice this rotation it's still correct but it's not fast enough right because now this ball is moving much faster which means it needs a faster rotation to make it look like it makes sense so how do we fix that you pick your sphere negative point you know maybe twice as fast negative 0.4 and now it's looking a bit better maybe something that might make sense right and ideally again there's a mathematically perfect way of doing this where this number is dictated by the length of the curve and I'm sure there's a way to do that once you dive into drivers and all this but for now we don't want to worry about that so let me just do a couple on dues and here's our set up and then finally just to make this look okay you can add in a point this is what I had as my demo scene so I just added it on plane and then we're just gonna want to make this a bit lower and since the sphere has a radius of 1 which means the whole thing has a diameter a height of 2 you just bring this down halfway so g4 grab Z minus 1 I believe and then that should be exactly correct yep and it's gonna look right for for somebody who doesn't know it's gonna look like it's rolling correctly notice how it's turning in a way that makes sense of course the beginning looks a bit awkward but that's just because our curve is very um sharp in the beginning you need to yeah basically this is like unnaturally sharp the curvatures too much but in general the idea is correct there and the nice thing about this is you can just duplicate the setup change the curve and have two balls going and change the shading to whatever you want so let me just quickly do that before we end the video shading instead of a noise texture we could do what I did before which was a wave texture and what I like about it is it's pretty simple it's just stripes going around and here you can really see the orientation right so it's kind of like off off kilter I don't I don't know what the word is but it's kind of like a I don't know how explain what I'm even thinking right now but there you go you now know how to roll a ball and blunder hopefully that was helpful you learn about constraints graph editor polynomials bit of shading stuff like that and if you enjoyed this free tutorial the best way to support me is over at my patreon yes that's right the end of the video patreon announcement seriously if you want to help support these tutorials and fund them so I can keep making them in the future patreon is the best way to do that and you also get benefits including stuff like discord benefits private access tutorial files and pretty soon for the next cg matter tutorial I make you're also going to get access to patreon exclusive tutorials which are just going to be like a more in-depth version of what I cover but generally does a donation but you can also buy benefits right so I really appreciate anybody who's willing to do that to help me out I really appreciate it and to help yourself out you get more tutorials but other than that I hope you enjoyed this free tutorial and that's it
Info
Channel: Default Cube
Views: 46,357
Rating: undefined out of 5
Keywords: blender, tutorial, ball, animation, roll
Id: fyilpH_X7dY
Channel Id: undefined
Length: 16min 42sec (1002 seconds)
Published: Fri Feb 14 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.