Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The Component Attributes window can also be used to add interactivity to a model. So for example, we have this refrigerator. So if want, I can interact with this refrigerator by opening and closing some doors, as well as sliding in and out the vegetable bins or the drawers in the bottom. So let's go ahead and see how this works. We are going to open up a file called Fridge_01 and this is basically the same refrigerator we had, but with no interactivity.
So the first thing we want to do is go ahead and slide out these bottom drawers. Now if you notice the refrigerator is positioned so that these drawers will slide along the green axis or the Y-axis. So let's go ahead and select this refrigerator, right-click and go into our Component Attributes. You can see the refrigerator is actually built of a number of parts. We have the master refrigerator component, as well as an upper and lower door component, and a left and right drawer.
We are going to start with the drawers. So like we said we want to slide this out along the green or the Y-axis. So we are going to add an attribute for right drawer, called Position Y. So again, this is a green axis and so we can see that at the default it's 35.3125. Now I am actually going to write that down because that's an important number. In fact, I can also just copy it, select it and just hit Copy, to remember that number, because what I need to do is I need to figure out what values this needs to animate through to slide the drawer in and out.
So if I just typed in a random number, say 50, you can see that well that's going the wrong way. So maybe something less than 35. Let's say 30. Okay 30 brings it out but I need to bring it out more. So how about 20? Well, 20 seems to slide that drawer out pretty much perfectly. So what I need to do is animate between 20 and this value, which is 35.3125. So I want this animation to happen when I interact or when I click on that drawer.
So what we need to do is add in an attribute and the attribute we want to find is called onClick. So when we click on that drawer, something happens and what happens is determined by a function. So let's go over here to Functions and let's just see what functions we have. If I scroll down, you can see here we actually have a whole list of onClick functions. So when I click on this, any one of these can happen. We can send out an alert. We can animate it four different ways, Fast, Slow, Custom and so on.
We can also go to a specific scene, we can redraw the scene, or we can set any other attribute. Now the one we are interested in is Animate. So let's go ahead and click on that. By clicking on that, all it does is it just puts it up here in this little holding area. We actually need to insert that into our onClick attribute. So I am going to click in here and then just hit Insert, and that puts in my function. So let's take a look at what we need to make this function work.
We want to animate an attribute. Well what attribute are we animating? We are animating Y and then we are going to animate it through any number of states, which means, for example, two states would be open and closed, or we could have open, half open, fully open, and so on. In this case, we really just want to deal with two states, but again you can have any number. So I want to go from state1, which is this number here 35.3125. state2 would be fully open and we remember that to be 20, and then we really don't need any more.
So all we need are these two states. When we click on this, we are going to animate the Y value between 35 and 20, hit Enter and let's see if it works. Let's go ahead and select Interact and you notice here that we can't interact with any of this and as soon as that hand goes over that bottom drawer, it lights up, and we can now interact. So we can do the same for the other drawer. So let's go ahead over to Drawer Left and add in that attribute.
Again we are going to animate along Y and conveniently enough, the values are going to be the same. This is 35.3125. So in fact, what we can do is we can just copy and paste the formula that we have here into our onClick function. So all I need to add in that onClick attribute. Then I am going to go here, highlight it, Ctrl+C or Apple+C to Copy, then hit Enter, and then Ctrl+V or Apple+V to Paste, Enter again.
And let's see how this works. Interact, one, two, there we go. So as you can see it's very easy to create custom interactive animations just by using onClick and the Animate function.
Get unlimited access to all courses for just $25/month.Become a member
100 Video lessons · 11467 Viewers
56 Video lessons · 10429 Viewers
83 Video lessons · 8305 Viewers
109 Video lessons · 3760 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.
Your file was successfully uploaded.