Main content
Pixar in a Box
Course: Pixar in a Box > Unit 9
Lesson 2: Code a character- Start here!
- 1. Creating objects
- 2. Representing a shape object in code
- Rigging a snowman 1 (building the body)
- 3. Putting shapes together
- Rigging a snowman 2 (adding a head)
- Rigging a snowman 3 (adding a hat)
- 4. Functions
- 5. Defining deformer functions in code
- Rigging a snowman 4 (coding deformers)
- 6. Connecting deformers and shapes with code
- Rigging a snowman 5 (adding and updating deformers)
- Project: Create your own character
- Project 2: Animate your character
© 2023 Khan AcademyTerms of usePrivacy PolicyCookie Notice
Start here!
Introduction to this lesson
Ready to dive into some code?
In this lesson you will build a simple snowman model and rig it using javascript. Then you can extend the model to create your own character in the final project.
You will be filling in some important pieces of a much larger program in this lesson—similar to how people work with software at Pixar.
Overview of lesson
First, you'll build some circles using objects.
Then you'll combine your various shapes in an array of objects.
Finally you'll write deformer functions so that you can move your model around.
By the end, you'll be ready for the final project!
What do you need to know before starting?
- If you've never programmed anything before, we recommend going through our Intro to JS course to learn the concepts of variables, arrays, functions, and objects. And, of course, come back here when you're ready!
- If you've programmed before but not on Khan Academy, we recommend getting comfortable with our environment first by creating a new program here.
- If you've learned programming here on Khan Academy, perfect! Just review the concepts below and refresh yourself on any skills you're rusty on.
- This lesson touches on math concepts—equations for geometric transformations—appropriate for grade eight and above. You can review this concept in our sets and staging lesson.
Quick review of programming concepts you'll use
Variables
- This creates a variable called start color #6495ed, start text, s, u, l, l, e, y, s, A, g, e, end text, end color #6495ed which stores the value start color #28ae7b, 15, end color #28ae7b.
Arrays
- This creates an array called start color #6495ed, start text, a, g, e, s, end text, end color #6495ed which stores three values start color #28ae7b, 2, end color #28ae7b, comma, start color #ff00af, 4, end color #ff00af, comma, start color #9d38bd, 8, end color #9d38bd.
- start color #6495ed, start text, a, g, e, s, end text, end color #6495ed, open bracket, 1, close bracket holds the value start color #ff00af, 4, end color #ff00af.
Functions
start text, v, a, r, end text, start color #6495ed, start text, space, s, a, y, H, e, l, l, o, end text, end color #6495ed, equals, start text, f, u, n, c, t, i, o, n, end text, left parenthesis, right parenthesis, space, left brace
start text, t, e, x, t, end text, left parenthesis, start text, start color #28ae7b, ", H, e, l, l, o, space, w, o, r, l, d, !, ", end color #28ae7b, end text, comma, start color #ff00af, 100, end color #ff00af, comma, start color #ff00af, 200, end color #ff00af, right parenthesis, ;
right brace
start text, t, e, x, t, end text, left parenthesis, start text, start color #28ae7b, ", H, e, l, l, o, space, w, o, r, l, d, !, ", end color #28ae7b, end text, comma, start color #ff00af, 100, end color #ff00af, comma, start color #ff00af, 200, end color #ff00af, right parenthesis, ;
right brace
- This creates a function called start color #6495ed, start text, s, a, y, H, e, l, l, o, end text, end color #6495ed that will output the text start text, start color #28ae7b, ", H, e, l, l, o, space, w, o, r, l, d, !, ", end color #28ae7b, end text at the screen coordinates left parenthesis, start color #ff00af, 100, comma, 200, end color #ff00af, right parenthesis when it's called.
start text, v, a, r, end text, start color #6495ed, start text, space, s, a, y, H, e, l, l, o, end text, end color #6495ed, equals, start text, f, u, n, c, t, i, o, n, end text, left parenthesis, start color #ff00af, x, end color #ff00af, comma, space, start color #ff00af, y, end color #ff00af, right parenthesis, space, left brace
start text, t, e, x, t, end text, left parenthesis, start text, start color #28ae7b, ", H, e, l, l, o, space, w, o, r, l, d, !, ", end color #28ae7b, end text, comma, space, start color #ff00af, x, end color #ff00af, comma, space, start color #ff00af, y, end color #ff00af, right parenthesis, ;
right brace
start text, t, e, x, t, end text, left parenthesis, start text, start color #28ae7b, ", H, e, l, l, o, space, w, o, r, l, d, !, ", end color #28ae7b, end text, comma, space, start color #ff00af, x, end color #ff00af, comma, space, start color #ff00af, y, end color #ff00af, right parenthesis, ;
right brace
- This start color #6495ed, start text, s, a, y, H, e, l, l, o, end text, end color #6495ed function now has two input parameters, start color #ff00af, x, end color #ff00af and start color #ff00af, y, end color #ff00af, to define the coordinates of the text.
Objects
- This creates an empty object called start color #6495ed, start text, s, n, o, w, m, a, n, end text, end color #6495ed.
start text, v, a, r, end text, start color #6495ed, start text, space, s, n, o, w, m, a, n, end text, end color #6495ed, equals, left brace
start color #28ae7b, start text, a, g, e, end text, end color #28ae7b, colon, start color #ff00af, 2, end color #ff00af, comma
start color #28ae7b, start text, c, o, l, o, r, end text, end color #28ae7b, colon, start color #ff00af, start text, ", w, h, i, t, e, ", end text, end color #ff00af, comma
start color #28ae7b, start text, l, i, k, e, s, end text, end color #28ae7b, colon, open bracket, start color #ff00af, start text, ", m, i, l, k, ", end text, end color #ff00af, comma, space, start color #ff00af, start text, ", c, o, l, d, space, d, a, y, s, ", end text, end color #ff00af, close bracket
right brace
start color #28ae7b, start text, a, g, e, end text, end color #28ae7b, colon, start color #ff00af, 2, end color #ff00af, comma
start color #28ae7b, start text, c, o, l, o, r, end text, end color #28ae7b, colon, start color #ff00af, start text, ", w, h, i, t, e, ", end text, end color #ff00af, comma
start color #28ae7b, start text, l, i, k, e, s, end text, end color #28ae7b, colon, open bracket, start color #ff00af, start text, ", m, i, l, k, ", end text, end color #ff00af, comma, space, start color #ff00af, start text, ", c, o, l, d, space, d, a, y, s, ", end text, end color #ff00af, close bracket
right brace
- The object start color #6495ed, start text, s, n, o, w, m, a, n, end text, end color #6495ed now contains three properties: start text, start color #6495ed, s, n, o, w, m, a, n, end color #6495ed, point, start color #28ae7b, a, g, e, end color #28ae7b, end text, equals, start color #ff00af, 2, end color #ff00af and start text, start color #6495ed, s, n, o, w, m, a, n, end color #6495ed, point, start color #28ae7b, c, o, l, o, r, end color #28ae7b, end text, equals, start color #ff00af, start text, ", w, h, i, t, e, ", end text, end color #ff00af. The third property of start text, start color #6495ed, s, n, o, w, m, a, n, end color #6495ed, end text is an array called start text, start color #28ae7b, l, i, k, e, s, end color #28ae7b, end text.
Have fun!
Want to join the conversation?
- all these comments are from 3 years ago im in the pandemic(16 votes)
- Well, I am 2 years after u! The pandemic is like done now.(3 votes)
- I am in 8 th grade and i have no idea still how to do this(2 votes)
- U can start back in the JS intro on KA, and that will help u understand it all!(1 vote)
- My gosh. This looks difficult. Has anyone been able to attempt and achieve this? I am not very good at understanding this set of instructions.(1 vote)
- I have, although it took me up to 1 hour and a half :((2 votes)
- how can we get in touch in other places(1 vote)
- im in the 10th grade(1 vote)
- heres how i talk(1 vote)
- and i still dont know how to do this(1 vote)
- We need lessons for blender(1 vote)
- how do i create boo from monsters inc(0 votes)