Start learning with our library of video tutorials taught by experts. Get started

Game Character Creation in Maya
Illustration by John Hersey

Controlling scripts with animation events


From:

Game Character Creation in Maya

with Chris Reilly

Video: Controlling scripts with animation events

In last video, we talked about how to make local copies of animations for editing inside Unity. In this video, we'll look at setting up animation events, which allow animations to access the power of scripts by calling script functions as they play. So let's use this run-read/write animation that we created in the last video. I'll go ahead and apply that to the Third Person Controller script which is attached to our game character. So in the hierarchy, I'll just click on a game character. And down here in this Third Person Controller script, instead of the read-only run animation, I want to use this run-RW animation.
Expand all | Collapse all
  1. 3m 50s
    1. Welcome
      39s
    2. What you need to know before watching this course
      1m 9s
    3. Understanding game asset creation
      1m 21s
    4. Using the exercise files
      41s
  2. 25m 35s
    1. Setting up scene folders (Maya and Unity)
      3m 58s
    2. Optimizing geometry
      3m 14s
    3. Using symmetry
      4m 8s
    4. Extruding geometry
      4m 19s
    5. Sculpting geometry
      4m 1s
    6. Importing reference sketches
      5m 55s
  3. 37m 14s
    1. Modeling the head and nose
      5m 34s
    2. Creating the mouth
      4m 28s
    3. Crafting the eyes
      5m 11s
    4. Building the body and a wing
      10m 11s
    5. Forming the limbs
      8m 5s
    6. Adding finishing touches
      3m 45s
  4. 36m 11s
    1. UV mapping overview
      2m 43s
    2. UV mapping the body parts
      9m 18s
    3. UV mapping the face
      7m 40s
    4. UV mapping wrap-up
      3m 44s
    5. Mirroring
      4m 57s
    6. Texturing
      2m 46s
    7. Normal mapping
      5m 3s
  5. 46m 21s
    1. Setting up the skeleton
      5m 19s
    2. Building the spine
      3m 39s
    3. Finishing the skeleton
      4m 32s
    4. Rigging the legs and feet
      8m 35s
    5. Rigging the torso
      3m 49s
    6. Rigging the arms and hands
      3m 35s
    7. Rigging the face and head
      5m 9s
    8. Rigging wrap-up
      2m 27s
    9. Skin binding and weight painting
      5m 26s
    10. Animating in Maya
      3m 50s
  6. 29m 9s
    1. Exploring the Unity interface
      3m 3s
    2. Importing character and animations into Unity
      5m 50s
    3. Controlling animations with scripts: Third-person character controller
      7m 14s
    4. Controlling animations with scripts: Third-person camera controller
      4m 4s
    5. Making read/write animations using UnityScript Editor
      4m 8s
    6. Controlling scripts with animation events
      4m 50s
  7. 19s
    1. Additional resources
      19s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
Game Character Creation in Maya
2h 58m Intermediate Sep 15, 2011

Viewers: in countries Watching now:

Get a thorough overview of techniques for creating characters for video games or real-time rendered applications. Author Chris Reilly covers low-poly modeling, texturing and animation, using 3D model and texture assets created in Maya and Adobe Photoshop. The course also includes an overview of Unity 3, including importing characters and making interactive animations with the Script Editor.

Topics include:
  • Optimizing, extruding, and sculpting geometry
  • Modeling a character's head and body
  • UV-mapping the head and body
  • Mirroring and texturing
  • Setting up the skeleton
  • Rigging the head and body
  • Skin binding & weight painting
  • Controlling animation with scripts in Unity
Subjects:
3D + Animation Modeling Character Animation Game Design
Software:
Maya
Author:
Chris Reilly

Controlling scripts with animation events

In last video, we talked about how to make local copies of animations for editing inside Unity. In this video, we'll look at setting up animation events, which allow animations to access the power of scripts by calling script functions as they play. So let's use this run-read/write animation that we created in the last video. I'll go ahead and apply that to the Third Person Controller script which is attached to our game character. So in the hierarchy, I'll just click on a game character. And down here in this Third Person Controller script, instead of the read-only run animation, I want to use this run-RW animation.

So I'll just click and drag, just drop that right on the Third Person Controller script. So now let's set up a script that this run-RW animation can talk to you as it plays. So in my Project panel, I'll click on Create > JavaScript. And we'll just title this HelloWorld. And I'll also go ahead and just create a folder for all my scripts.

And I'll just click and drag to place that in Scripts. So right now this is just a blank script, so I'll double-click and we can make some edits here. So right now, we have a default function called the Update function. So that's a function that automatically comes up in any script and there we could place scripting language to control things that happen every frame. In this case though, we're just going to make a very simple function. So I'm just going to type function and I'll title it Running.

And all our function is going to do is output some text to the console. So the command to do that is Debug.Log and then we can just type in our message. So I'm just going to have him say "I'm running." So this is about as simple as you can possibly get with a function. If you don't have much experience with JavaScripting for Unity, again I would take a look at some of the documentation. There are some really great tutorials for scripting.

And it's actually a lot of fun. You can do some really powerful things with scripts though Unity. So let's go ahead and save this. And we can quit out of our text editor. Whoops! I'm getting an error down here already. So let me just double-click one more time. I forgot my semicolon here. Okay. So I want to take the script, left-click, drag over to the hierarchy, and just apply it to our game character. So now let's click on root again and go in and add an animation event to our read/write animation.

So I'll bring up the animation window by clicking Window > Animation and we'll edit our run-RW animation. So in the timeline here, right below there's this little track and that holds animation events. So I can drag the time slider out. Let's say halfway through I want to add an animation event here and I can just click Add Event, so I've got an event here. And right now, there's no function selected. So basically an animation event is just going to talk to any of the scripts that are attached to the game object that you're animating.

So to edit this, I can just double-click and it's going to ask me to pick a function. So right now I get a big list. So these are all the functions from all the scripts that are attached to my game character right now. What I want to pick is this Running function. So as this animation plays, when it hits this point, it's going to call that Running function that we just set up in our script and it's going to print that text to the console. Okay, so I'll close out of the animation window.

And I'll go to Window. It'll bring up the console so we can actually see the text that we're going to get when we play. And I'll just click this tab here, just drag it right down to the Project window. So one thing about the Unity interface is it's really easy to customize, so you can reposition and drag around windows as you need to. So I'll go ahead and switch to my Game view. Let's go ahead and play. So I'm going to hold down Shift+W and I should see in the console now my text is appearing as that running animation plays over and over again.

So that's a really simple example of how to get an animation to talk to a script. Now obviously, you would probably want to do something more elaborate with your script. You could use it to control other game objects that are in your scene, maybe turn a light on or off, something like that. Really, the sky is the limit and it's just a matter of getting familiar with scripting and getting familiar with Unity.

There are currently no FAQs about Game Character Creation in Maya.

Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Game Character Creation in Maya.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked

Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.