Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
We can also use interactivity to rotate things such as the doors of this refrigerator. We already have this set up, so that we can interact with the drawers. But right now, the upper and lower doors of this refrigerator don't work. So let's go ahead and make them work. I am going to go ahead and select the Refrigerator, go into Dynamic Components > Component Attributes. Let's go ahead and work on this lower door, the bigger one, and we are going to go ahead and add an attribute.
Well what attribute do we want to add? Well, we want it to rotate around the vertical axis, which is our Y or our blue axis. So let's go ahead and add attribute, RotZ. We can see here that the default value is 90. So we can rotate it between, say for example, 90 and 0. But as you can see it's rotating the wrong way. It's rotating around the wrong axis. So let's go ahead and put that back to 90 and we need to change the axis. Now in order to do this, we have to find the component, so I am going to click on the refrigerator, double-click to open that up, select the lower door, and then right-click and find Change Axes.
You can also do it here. You can also just do under Component, there is also a Change Axes. Either one of those will work. So what this does is it gives us an axis that we can pretty much place anywhere. Well, I want it to snap to this lower point here, see if I can get that in there. Or you can snap it up here. It just depends on where you want it, just as long as it's anywhere along this line. So I just wanted to snap here and once I've done that, now this should work.
So it goes from 0 to 90, and you can see how it opens. Well actually we don't want to go to 90. We wanted to go to -90 or the other way. So from -90 is closed and 0 is open. So we need to animate between those. So let's add in our onClick attribute, and again we want to put in Animate. So we can just type it in if we want. We don't have to select it from the list.
And what are we animating? Well we are animating RotZ. Now I want to make sure that I put this in quotes, so Animate"RotZ", and I want to animate it from 0 to, so 0,-90. Once you have all that in, hit Enter, and we should have something that works. There we go. Okay, so let's do this one more time for the upper door. Now before I do this, I just want to make sure I check where my axes is, because that was a problem with the other door.
Let's go ahead and right-click over this, and hit Change Axes, and again we have that same problem. So I am just going to go ahead and put that up in the corner there and let's go ahead and add in an attribute, RotZ. So right now we have 0, and I bet it's going to operate pretty much the same, from 0 to -90. Okay, so there we go. So we are going to have pretty much the same behavior. So let's go ahead and add in onClick and then Animate. We can just type that in and what are we animating? We are animating RotZ.
Again, make sure you put this in quotes, from zero to -90. In fact, we probably could have just copied and pasted that from the other value. So now that we have that, we should be able to interact with this. So now, we have got a fridge that opens and closes and the drawers slide in and out. And isn't that pretty cool? So as you can see, you can use onClick to also animate rotations. So doors can open and close.
You can also animate any other type of attribute using the same types of techniques.
Get unlimited access to all courses for just $25/month.Become a member
109 Video lessons · 8629 Viewers
102 Video lessons · 6528 Viewers
56 Video lessons · 13562 Viewers
83 Video lessons · 11350 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.