Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
So now let's take a look at how to do rotation interactively. Now we already have this refrigerator set up so that the drawers are interactive, and they actually are moving, their position is changing, but let's go ahead and add some interactivity to these doors. So I'm going to go into my Component Attributes window and let's take a look at the two doors. We're going to go ahead and work with Door_Lower and we're going to first of all add an attribute.
So what attribute do we want to add? Well we want to do rotation, so which axis do we want to rotate around. Well we want to rotate around the Z axis; In fact, you can see it up here that that's the rotation, because we're going to rotate around that vertical axis there and that's a little handy visual guide. So we're going to add in Rotate Z. So Right now, it's at 90, so let's go ahead and just type in another number. Let's type in 0 and see what happens. If I type in 0, well you can see how this is rotating around the wrong axis, it's actually rotating somewhere around here and we don't want that, so I'm going to put it back to where it was, put it back to 90 and what we need to do is we need to change the axis, change where this is rotating.
Right now, it's rotating around this edge and we wanted to rotate around this edge, so what we need to do is move that hinge or that pivot point. We can do it by selecting this component here. I'm going to select that component and then do Change Axes, or we can right-click over this and do Change Axes as well. And when we do that it brings up this little kind of cross here and what this does is this is where it's going to rotate.
So I want to make sure that this snaps to that inside edge, just long as I get it on that inside edge I should be okay and then hit Enter and we should be okay. Now once I've done that, notice how my Rotation changed to 0 from 90. So now I've got my Rotation at 0, so let's see what 90 does. Well that opens a door a little too much. So I'm going to go ahead and hit 0 Again, and let's bring it back to -90, let's bring it the other direction.
So if I do that notice how the door closes. So when I go ahead and put this back at 0 and now, I now have the information I need to add my interactivity. So I'm going to ahead and add an attribute here, I'm going to add onClick and into this we're going to add Animate again. So if we want we can just type it in, or we can go to our Functions here. We can go Animate, or If want we can type it in. So let's just type it in, I'm going to type in the word Animate and then what do I want to animate.
I want to animate Rotate Z. I want to make sure that that's in quotes. So animate("RotZ" and I want to go from 0, -90. So I'm going to rotate in Z from 0 to -90, hit Enter and let's see what happens. So tools>Interact, well it's active, here it goes. Perfect! Well now that we have figured out the lower door the upper door should be pretty much the same. So let's go ahead and add attribute Rotate Z and I'm pretty sure that the pivot is not going to be in the right place, but I can always change it, so let's go ahead and find that door and let's do Change Axes.
You can see that's where my axis is, and again, I just want to snap it in there. Let's go ahead and make sure that -90 is a proper value, yes, that what closes it. So again, this is the exact same behavior as the one before. So what I can do is I can literally just copy and paste that attribute. So I'm going to go into this onClick for Door_Lower, add an attribute for onClick on Door_Upper, Copy and Paste that variable and we should have it working.
So I'm going to go ahead and do Interact, close, open, here we go; a perfectly good refrigerator. As you can see rotation is a little bit different than translation, you have to have one more step. You want to make sure that the axes are in the right place, or else it's going to be rotating around the wrong place. But also remember that the onClick and Animate functions can be used for just about any attribute, you're not just restricted to rotation and position, you can do it for just about anything.
Get unlimited access to all courses for just $25/month.Become a member
109 Video lessons · 11350 Viewers
102 Video lessons · 8524 Viewers
56 Video lessons · 15291 Viewers
97 Video lessons · 10466 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.