O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learning Unity Physics

Book Description

Learn to implement physics in interactive development using the powerful components of Unity3D

In Detail

Unity is a powerful game development engine that provides rich functionalities to create 2D and 3D games. Developers get the opportunity to build cross-platform mobile and desktop games from scratch. With the increasing interest in using Physics in interactive development, Unity3D offers a cutting-edge platform for simulation, game development, and application development through a user-friendly interface. You will learn the fundamentals of Physics in game development. The book starts by providing a quick introduction on how we can use Physics for interactive development. Furthermore, it provides a detailed description on the uses of Physics material in Unity3D and how we can use different colliders for interaction. The book also focuses on Rigidbodies and Joints, its types and properties. There is also a dedicated section on how we can optimize applications and games if we use Physics in Unity3D. By the end of this book, you will be capable of successfully developing Physics-based simulations, games, and applications.

What You Will Learn

  • Discover the use of Physics in interactive development
  • Explore the built-in Physics components of Unity3D
  • Get to grips with the uses and types of different colliders in Unity3D
  • Define the collision shape of objects in scenes, explaining the Collision Matrix
  • Learn in detail the uses and types of different Rigidbodies in Unity3D
  • Get to know more about Joints and their types with examples
  • Make use of Unity3D Physics components for animation
  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. Learning Unity Physics
      1. Table of Contents
      2. Learning Unity Physics
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Errata
          2. Piracy
          3. Questions
      8. 1. Introduction to Physics in Unity3D
        1. The most common component of Physics used in interactive development
          1. Use of Physics in simulation and frame rate
        2. Basic components of Physics for interactive development
          1. Integration
          2. Collision detection
          3. Collision resolution
        3. Physical simulation in Unity
          1. Built-in Physics in Unity3D
          2. Built-in Physics components in Unity3D
            1. Rigidbodies
            2. Kinematic motion and Rigidbodies
            3. Colliders
              1. Static colliders
              2. Dynamic colliders
              3. Physic Materials
            4. Triggers
            5. Joints
            6. Character controllers
            7. Scripting based on collision
            8. Frictionless Physic Materials
        4. Summary
      9. 2. Using Different Colliders for Interaction
        1. Primitive colliders
          1. Types of primitive colliders
            1. Box Collider 3D
              1. Example – implementation of Box Collider
            2. Box Collider 2D
            3. Sphere Collider 3D
              1. Example – implementation of Sphere Collider
            4. Circle Collider 2D
            5. Capsule Collider 3D
              1. Example – implementation of Capsule Collider
            6. Mesh Collider
              1. Example – implementation of Mesh Collider
            7. Polygon Collider 2D
              1. Example – implementation of Polygon Collider 2D
            8. Edge Collider 2D
        2. Nonprimitive colliders
          1. Types of nonprimitive colliders
            1. Wheel Collider
              1. Example – implementation of Wheel Colliders
            2. Static collider
            3. Rigidbody Collider
            4. Kinematic Rigidbody Collider
            5. Trigger Collider
              1. An example of proximity triggers
              2. An example of radius triggers
        3. Compound colliders
          1. Example – implementation of compound colliders
        4. Summary
      10. 3. Overview of Collision Matrix
        1. Collision Matrix 3D
        2. Trigger Matrix
          1. Matrix for 2D Objects
        3. Layers and Collision Matrix
          1. An example of a layer-based Collision Matrix
          2. Collision Matrix and a script
            1. An example of a script-based Collision Matrix
        4. Summary
      11. 4. Rigidbody Types and Their Properties
        1. Types of Rigidbody components
          1. Physics Rigidbody
            1. An example of creating a Physics Rigidbody
          2. Kinematic Rigidbody
        2. Properties of Rigidbody components
        3. Example using a Rigidbody
        4. Summary
      12. 5. Joint Types and Their Properties
        1. Types of joints
          1. Fixed joint
          2. Spring joint
          3. Hinge joint
          4. Character joints
          5. Configurable joints
            1. Handling movement/rotation restriction
              1. Limiting motions
              2. Limiting rotation
            2. Handling movement/rotation acceleration
              1. Handling translation acceleration
              2. Handling rotation acceleration
        2. Summary
      13. 6. Animation and Unity3D Physics
        1. Developing simple and complex animations
          1. Interpolate and Extrapolate
          2. The Cloth component
            1. Important points while using the Cloth component
          3. ConstantForce
            1. An example of animation using ConstantForce
            2. An example of animation using AddForce
            3. An example of animation using AddTorque
            4. An example of rope animation using different joints
        2. Summary
      14. 7. Optimizing Application's Performance Using Physics in Unity3D
        1. Developing an optimized application and game
          1. Checking performance
          2. Moving static colliders
          3. Mesh Colliders
          4. The complex collider shape
          5. Rigidbodies
          6. Joints
          7. The Cloth component
          8. Lower timestep
          9. Precalculation
          10. Optimizing graphics
          11. Script call optimization for an iOS build
        2. Pros of performance optimization
        3. Summary
      15. Index