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

Unity 4.3 Essential Training
Illustration by Mark Todd

Exploring physics


From:

Unity 4.3 Essential Training

with Adam Crespi

Video: Exploring physics

Physics in a game engine provides a terrific I'll put it in, spin around, and move it through the doors.
Expand all | Collapse all
  1. 2m 57s
    1. Welcome
      41s
    2. What you should know before watching this course
      52s
    3. Using the exercise files
      1m 24s
  2. 21m 21s
    1. Designing the game
      4m 39s
    2. Setting the project
      4m 9s
    3. Exploring the Hierarchy, Scene, and Inspector windows
      5m 45s
    4. Creating and transforming objects
      6m 48s
  3. 21m 34s
    1. Organizing the Assets window
      2m 55s
    2. Exporting objects from 3D modeling programs
      8m 33s
    3. Importing and configuring models and textures
      4m 54s
    4. Setting properties for models and textures in the Inspector
      5m 12s
  4. 29m 8s
    1. Introducing the game environment
      4m 27s
    2. Placing the player controller
      4m 29s
    3. Publishing project settings
      5m 32s
    4. Adding sky and fog
      8m 17s
    5. Fine-tuning the First Person Controller
      6m 23s
  5. 57m 25s
    1. Creating the terrain geometry
      3m 29s
    2. Forming the topography
      9m 54s
    3. Painting the terrain textures
      7m 9s
    4. Painting trees and forests
      10m 55s
    5. Painting grass, shrubs, and 3D geometry
      9m 38s
    6. Painting detail meshes
      8m 46s
    7. Adjusting terrain settings
      7m 34s
  6. 39m 45s
    1. Creating materials and assigning shaders
      8m 56s
    2. Handling multiple materials
      7m 13s
    3. Adding textures to a material
      3m 57s
    4. Manipulating textures
      5m 20s
    5. Adding reflections to materials
      8m 1s
    6. Creating lit materials
      6m 18s
  7. 47m 12s
    1. Creating GameObjects
      5m 2s
    2. Understanding components
      6m 15s
    3. Using colliders for barriers
      6m 22s
    4. Using colliders for triggers
      8m 1s
    5. Exploring physics
      8m 22s
    6. Working with Physic materials
      5m 3s
    7. Adding joints to rigid bodies
      8m 7s
  8. 20m 33s
    1. Setting up prefabs for animation and batching
      5m 8s
    2. Animating an object
      6m 32s
    3. Adjusting timing in an animation
      3m 50s
    4. Animating transparency and lights
      5m 3s
  9. 11m 58s
    1. Importing skinned meshes
      4m 51s
    2. Separating animations into clips and states
      3m 14s
    3. Creating transitions between states
      3m 53s
  10. 30m 22s
    1. Customizing ambient light
      2m 59s
    2. Creating the sun using a directional light
      5m 49s
    3. Using layers and tags for lighting
      3m 32s
    4. Adding spot and point lights
      4m 25s
    5. Using point lights for fill
      4m 30s
    6. Adding and fine-tuning shadows
      5m 10s
    7. Creating lighting effects with cookies
      3m 57s
  11. 9m 15s
    1. Adding scripts to GameObjects
      2m 42s
    2. Using correct script syntax
      6m 33s
  12. 23m 7s
    1. Setting up a 2D project
      3m 13s
    2. Importing sprites
      2m 30s
    3. Slicing in the Sprite Editor
      3m 6s
    4. Layering sprites and setting the sorting order
      5m 12s
    5. Creating 2D colliders
      3m 12s
    6. Adding 2D physics
      2m 25s
    7. Animating 2D elements
      3m 29s
  13. 30m 25s
    1. Creating light shafts and sunbeams
      5m 20s
    2. Using ambient occlusion to add gravity
      4m 37s
    3. Adding depth of field
      8m 40s
    4. Applying motion blur
      5m 46s
    5. Tuning color for mood
      6m 2s
  14. 38m 16s
    1. Exploring water effects
      7m 36s
    2. Working with wind zones
      2m 8s
    3. Using an audio source
      4m 3s
    4. Creating a sound zone
      5m 59s
    5. Triggering audio
      3m 37s
    6. Adding audio effects
      3m 13s
    7. Creating particle systems
      2m 26s
    8. Adjusting particle systems
      9m 14s
  15. 25m 23s
    1. Setting up occlusion culling
      5m 52s
    2. Enabling batching to reduce draw calls
      3m 28s
    3. Testing in the game window using statistics
      4m 27s
    4. Building a development build and debugging
      6m 0s
    5. Building the executable
      5m 36s
  16. 49s
    1. Next steps
      49s

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 ...
Unity 4.3 Essential Training
6h 49m Beginner Mar 10, 2014

Viewers: in countries Watching now:

Interested in game making? Start in Unity—a game engine for mobile and desktop games and real-time simulations. Author Adam Crespi shows techniques used in game development with Unity and introduces the basics of scripting and game functionality. First, learn how to import models and textures, organize your project and hierarchies, and add terrain, water, and foliage. Next, Adam explores how to use lighting to bring the game to life, and add rendering, particles, and interactivity. The end result is a sample game with a lush environment, fully animated characters, and some basic interactive gameplay.

Topics include:
  • Designing the game
  • Creating and transforming objects
  • Importing and configuring models and textures
  • Setting properties in the Inspector
  • Creating the terrain geometry
  • Building materials and adding shaders
  • Creating GameObjects
  • Exploring physics
  • Animating objects
  • Lighting the scene
  • Creating 2D game elements
  • Adding special effects
Subjects:
3D + Animation Developer Games Game Design Game Development
Software:
Unity 3D Unity
Author:
Adam Crespi

Exploring physics

Physics in a game engine provides a terrific way to add interactivity and fun in the environment. What physics lets you do is attach rigid bodies or similar colliders to an object and tell them yes, please react when you're hit. You have a mass and so forth. And so you can do things like knock over art, for example, in this gallery. We can also do things like crash into door and fling them open. And even get as far as dealing with hinged objects and chains and so on. We'll start out by putting some art into the gallery that we can knock over.

I've brought in a new FBX called Tower Sculpture. And it's exported out in centimeters so the scale of 0.01 is correct. It's three abstract, modern, tower sculptures made of plaster. And we're going to place them in here, get some colliders on, and let the player knock them over. What I'll do to start is take this tower sculpture and drag it into the scene. I'll put it in, spin around, and move it through the doors. I'll press F to focus in. And there's my sculpture. This is a place, a lot of times, where I'll turn off the lighting, and that way I can see things in a default shading mode a little more clearly.

Because I haven't really lit the place yet. I'll pull this sculpture into place where I'd like it. Probably over here, right in the sun and by this big wall. Now, we're going to let the player knock these over, so we need to add a couple of components on. I'll pick the first tower sculpture. And add a box collider. When you're dealing with physics, two mesh colliders can't collide together. So we need to use other colliders. And this is where, if you need child colliders, such as multiple boxes, to approximate the shape of an object, you can use them.

These towers are close enough to boxes. And have enough edges that stick out, that I'll use a box. There's one and two, and finally, three. Now, with all of them having a box collider, I need to put one more component on. I'll put on a rigid body, choosing under Component>Physics>Rigid Body. The rigid body, then, specifies a mass, a drag, an angular drag. The possibility of using gravity is kinematic and we'll deal with that if we have animation that needs to turn off and on and then react with physics.

And then we have different interpolation and collision detection methods. We'll use the default here, no interpolation and discreet collision. Basically what that says is, when you are collided with, please do something. And that's different form continuously looking or looking dynamically and some other different ways of checking. We're going to say it's discreet because it's when the player knocks into this object, it will knock over the art. Under constraints in the rigid body then, we can say, well, you can rotate. And maybe on a certain axis.

Or you can't move, but you can only rotate. And this is handy for making things that are hinged, for example. I'll leave it alone, because I'd like the player to be able to accidentally knock over the art. A big no, no in an art gallery usually is to touch the art. And so, we're going to let these be here and the player can bumble into them. I'll add a rigid body onto the other pieces choosing Component>Physics>Rigid Body. And one more time. Component>Physics>Rigid Body. This works so far, and everything is set. I want gravity on, and I'm going to leave the mass alone and see how it behaves.

However, our character controller won't collide with it initially. I'll play this to show how it looks. I'm in my scene, dark though it is, and there's my towers and I can bump into them. It's working at least, they're box colliders, because I can not pass through them, but I'm not knocking them over yet. What I need to do to make this work with the character specifically, the player, is to add a script onto that character. That acknowledges that the characters collider is hitting another collider. This is from the Unity help and I've included it in a word document in the assets folder in the scripts here, so we can simply copy and paste into a new JavaScript and MonoDevelop.

I'll put a new script on, selecting that first person controller. Scrolling down to the bottom to add a component and I'll roll up some of the other pieces so I have a little more real estate to work on. Choosing Add Component > New Script, and in the new script I'll set my language to JavaScript and I'll call this new script character hit. I'll hit Create and Add. And now I've got the script, which is blank, and I can get those script elements in. To edit a script, you can drop down on the gear and choose Edit Script.

And Unity will pull up MonoDevelop. MonoDevelop is a powerful scripting and programming application that comes with Unity and works in multiple languages and is tremendously handy for scripting in things here for your game. The default script in JavaScript for character hit looks like this. Basically it says, we're working in a strict pragma, strict language we'll call it, and do something. Function start and function update. When the game starts, do something. And when the update happens, do something.

We're going to replace that with this character controller script. What I'll do is open up that Word document and just copy and paste over. I've opened up the Word document from the scripts directory in the project assets. And this is what the script looks like. In scripting, in short, because we'll get into more scripting later, when things are preceded by a double slash, they are commented out. And therefore, the lines of the script we're looking at to start, are variable push power. How much power does the character have? Function on character controller collider hit, when we hit something, do something.

We have an attached rigid body. Basically what that says is, when you hit something you have a rigid body because the character controller does not have one initially and then, if you hit it, what do you do? What it also says is, we have a variable push direction in a vector three. That's our x, y, z. And this is restricted, so we don't push things that are below us. And then, the last part of it, apply the push. The velocity of the character, plus the push direction, times the push power.

And that gives us the application of that push. I'll take this and copy and paste it into MonoDevelop by pressing Ctrl+A, Ctrl+C for copy. Switching over to MonoDevelop and pasting in. I've pasted straight in, taking out the functions section and now my JavaScript is ready. I'll save this script by pressing Ctrl+S and go back to Unity, where that script will automatically be updated and loaded. Back here in Unity, with the script updated, I can see now I have a push power section, and that's the push power I can add to that character.

I'll try this out again, and what I'll also do is put a light in so I can actually see what's going on. I'll choose Game Object > Create Other > Point Light. I'll move this point light over. As long as I've got something to see beyond grey, that will work. I'll pick my character controller, and there's a push power of two. I'll try it out at four and see if this works. I'll press Play and go knock over the art. It worked. I jumped over one and knocked into the others. And they fell over. I'll try this one more time from a different angle and see how it looks.

I'll press Play, go into my scene, come around to the other side, I'll go look at these neat modern sculptures and accidentally, whoops, knock one over. Now, this should freak out the player just a little bit, which should bring a smile to you as the game designer, because what do we do in an art gallery typically? We look. And so to have somebody be able to knock it over and not know how to pick it up adds a unique element to this game. And more importantly, we've put some physics in our world. What we've done is not just put a collider on where we can just simply bump into them and stop.

But we've told them, yes, please react. And you've got a rigid body so you fall and don't break, and you don't bend. And react with gravity. And so we can make it fall over and now we have fallen art in the gallery.

There are currently no FAQs about Unity 4.3 Essential Training.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

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.

join now 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 Unity 4.3 Essential Training.

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
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.

Are you sure you want to delete this note?

No

Notes cannot be added for locked videos.

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.