Step-by-step procedures for creating a path of motion for 3D geometry. A simple math expression to make the object always point in the direction of the path is demonstrated plus how to alter both the path and the objects speed along the path.
- [Voiceover] Hi, this is Steve Wright welcoming you to this week's NUKE Nugget, how to make an object stay pointed in the direction of travel, while following a path of motion. Now, motion graphic apps, like After Effects, have a path of motion feature built in, where the object stays pointed in the direction of travel, but NUKE does not. However, we can duplicate this feature in NUKE with a simple time expression and make this jet fighter fly the path of motion and automatically stay pointed in the direction of travel. So, we're gonna make this jet fly and weave through these pillars, in fact, we're gonna end up having him bank and weave through the pillars using a path of motion.
Okay, so, to make our path of motion, we'll need an Axis node. We'll come over to the 3D tab. Grab an Axis node. Let's put it over here, just to the right of the ReadGeo node for our jet fighter, okay? We'll switch the viewer to a top view by typing C on the keyboard. Make sure our play head is on frame one, 'cause we're gonna animate Mr. Axis. Pushed in a little too far. We'll select our Axis and let's position him right about there, and we have to set the axis translate key frame, there we go.
All right, let's go to the last frame, and move our axis down here. All right, so the axis now will follow this straight path. What we want to do now is let's give it some curves, so we're gonna weave around these pillars. So, by sliding the play head to where the axis is, is near this pillar, I can just pull it over here like that. Slide the play head to working on the next pillar, and we'll do this, and the third pillar, we'll do that.
Okay, now, switch to a perspective view, selecting our path of motion. Now, let's get it up off the ground. So, positioning the play head on frame one, I'll just grab Mr. Axis and pull him up in the air, and then we'll go to the next key frame, get him up in the air, and the next key frame, up in the air, key frame, up, and last, way up.
Okay, so, now we have a very interesting three dimensional path of motion, and we want the jet to follow it and stay oriented automatically, okay? All right, so let's make that happen. So, to the ReadGeo node for the jet fighter, let's add a TransformGeo, so we'll go the the 3D tab, Modify, TransformGeo, and hooks it in. Next, hook up the loop input to the Axis node.
Now, just to de-conflict our data pipes, let's add a control point here and give it a little bend. You'll see in a minute why you need that. Okay. All right, now, all we've accomplished, however, is the jet will now always look at the axis. Here we are. Okay, that's a piece of the puzzle. We'll see in a minute, this would work just fine. Next, we need to get the jet to jump onto our path of motion, and that's easy to do.
I'm going to open up the Axis node, command + double-click, so it's floated over here, because I need to link the Axis node to the TransformGeo node here, so, holding down command + control, click, drag, and drop, okay. We can close our Axis node. Now the jet is following the path of motion, but it's not yet orienting automatically, okay. That's where we have to do our little time trick, so let me get up here, so you can really see the jet's orientation.
So, let's double-click on the TransformGeo node to put it at the top of the Property bin, and we'll open up the Translate fields to edit the expression. So, I'll click on the animation curve, select Edit expression. Okay, so here's where the magic happens. I'm going to add a math expression behind the Link command, paren, frame, minus one, paren, okay, which means the position will be one frame back from wherever the play head is.
All right, we'll see the importance of that in just a second, so let's copy this, and paste it on the other two, so now all three expressions have the frame minus one added to it. Watch the behavior of the jet when I click OK. Boom, oriented. Now, you see that? The jet is now staying oriented on the path even as I move the play head. Here is the Axis node data where you can see that the jet is looking at the Axis node location on the current frame, which is 93, but it is positioned on the current frame minus one, which is frame 92.
That's why he's always looking in the direction of travel. In fact, if we zoom out here a little bit, we can see that he's even pointing up in the air as he goes off the end there. Very nice. Now, there is a little technical issue we need to address. Let me cruise up here. In fact, I'll switch to the top view by typing C on the keyboard. If I move the play head to the first frame, with a push into this guy here, jump to the first frame, it'll lose the orientation.
It doesn't become properly oriented until frame two. The reason is, it's look is on frame two, but it's position is on frame one, but if I go to play head frame one, the look is on one, and the position is on one, so there's no orientation information, so what we need to do is very, very simple. We're gonna take the key frame for the axis on frame one and simply slide it to frame zero.
So, all we have to do is come in here to the Dope Sheet. Let me move the play head off, so I can see what I'm doing here, and I'll grab these three X, Y, and Z guys right here and just shift them to frame zero, that's all. Now, if I jump to frame one, the plane is oriented. If I go to frame zero, he'll lose orientation, but now, on frame one, he'll look at the Axis node on frame one, but he'll position on the Axis node where it is on frame zero.
So, if you want to change the path of motion, that's just a matter of repositioning the axis. So, let's say we come out here to this frame, and we can just move the control point for the axis and that'll change the path of motion. If we wanna change the speed, we can do that too, so right now, watch the speed of the plane. It's taking 200 frames to traverse the entire path. Okay, so there we go, okay. Go back to frame one. So, if however, I'll home my Dope Sheet, I'll select all of the points in here, like so.
Now, if I just squeeze them all to frame 100, it's gonna now traverse the entire path in only 100 frames, so it's gonna go twice as fast. And there we go. Done, okay? Put that back to the beginning and I will undo my speed change. If I wanted to change the speed in just one part of it, let's say right around here, on this key frame, then I can just come in here and grab just that key frame and move it forward or backward in time.
If I move it this way, the plane's gonna go a lot slower. It's gonna take more frames to get here. Go this way, it'll go faster, 'cause now it'll have fewer frames to get to the same position. So, undo that. So, we've got global speed change control and local speed change control. Okay, just for good effect, let's finish this off by giving our plane some nifty banking action. Okay, let me put up that Axis node, 'cause I wanna see that path of motion here. So, let's animate the plane's banking left and right.
We'll go to frame one. And we can do that in the ReadGeo node. We'll scroll down here, and now I can use the rotate Z to bank the plane. So, I'll undo that back to zero and let's set a key frame on frame one, don't forget, play head on frame one. We'll jump to the next key frame. Let's cruise over here, and let's give it a bank of like so. We'll jump to the next key frame, and we'll bank in the other direction, and we'll go to the next key frame, bank it back this way, and then the last key frame, we'll zero off the bank entirely.
All right. Now. We have a plane that will follow our path of motion, stay oriented, and bank beautifully over the entire length of the shot. Here we go. Here we are, very, very nice. So, there you have it. A path of motion animation automatically pointed in the direction of travel. Be sure to check in next week so you don't miss out on my next NUKE Nugget.
What kinds of NUKE tips do you need? Join the Steve Wright's NUKE NUGGETS group on LinkedIn, and post your requests there.
Skill Level Intermediate
Q: Why can't I earn a Certificate of Completion for this course?
A: We publish a new tutorial or tutorials for this course on a regular basis. We are unable to offer a Certificate of Completion because it is an ever-evolving course that is not designed to be completed. Check back often for new movies.