Presentation is loading. Please wait.

Presentation is loading. Please wait.

Done already for your convenience!

Similar presentations


Presentation on theme: "Done already for your convenience!"— Presentation transcript:

1 Done already for your convenience!
2D Physics Engine Done already for your convenience! Unity 2D Game Development Telerik Academy Plus

2 Three Seminars Part 1 Part 2 Part 3
* Three Seminars Part 1 Intro to Unity 3D and 2D Game Development Basic Math for 2D Game Development 2D Graphics and Animations Part 2 2D Physics Engine Game Scripting with C# UI and Audio Part 3 Building a 2D Game (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

3 Table of Contents 2D Physics Overview RigidBody 2D Colliders 2D Forces
* Table of Contents 2D Physics Overview RigidBody 2D Colliders 2D Circle Collider 2D Box Collider 2D Polygon Collider 2D Edge Collider 2D Forces (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

4 Rigidbodies, Colliders, Joints, etc.
* 2D Physics Overview Rigidbodies, Colliders, Joints, etc. (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

5 2D Physics Overview All physics elements are normal components
* 2D Physics Overview All physics elements are normal components Just add them to a game object Set all needed properties The physics engine will start using them Enjoy the effects  (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

6 2D Physics Overview Rigidbodies
* 2D Physics Overview Rigidbodies Main component for the Physics Engine to start With Rigidbody the object will start to respond to gravity If you enable Rigidbody, you should not try to change the Transform part of the object Instead, you should apply forces and let the engine do the heavy lifting If you need non-moving by the engine Rigidbody, check “Is Kinematic” option (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

7 2D Physics Overview Colliders
* 2D Physics Overview Colliders Define the shape of an object in terms of physical collisions Most of the time invisible Use Box Collider and Circle Collider whenever possible for performance reasons Otherwise use Polygon Collider Colliders with Rididbody are dynamic colliders Colliders without Rigidbody are the static environment in your game – walls, floor, etc. (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

8 2D Physics Overview Physic Materials
* 2D Physics Overview Physic Materials Materials define the physics collision effect For example – ice is slippery, rubber has friction Usually parameters are found by trial-error In 2D there are two parameters Friction – friction coefficient Bounciness – the degree to which collisions rebound from the surface 0 – no bounce effect 1 – full bounce effect with no loss of energy (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

9 2D Physics Overview Joints Attaching two rigidbodies to a fixed point
* 2D Physics Overview Joints Attaching two rigidbodies to a fixed point Allow restricted movement Rotation by the three axes Translation by the three axes Stretching like a spring You can set joint to break if certain force is applied (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

10 2D Physics Overview Different Types of Colliders
* 2D Physics Overview Different Types of Colliders Trigger Collider – does not respond to physics calculations but sends event to which you can subscribe from the scripts OnCollisionEnter2D / OnTriggerEnter2D – when two colliders starts colliding for the first time OnCollisionStay2D / OnTriggerStay2D – when two colliders are colliding OnCollisionExit2D / OnTriggerExit2D – when colliders are no longer colliding Simply select “Is Trigger” (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

11 2D Physics Overview Different Types of Colliders
* 2D Physics Overview Different Types of Colliders Static Collider – object with collider but no Rigidbody Used for level geometry and should never move Should not be disabled or enabled If you do, major performance decrease may occur Also – calculation errors in the engine may occur If you want to alter it – add Rigidbody to it (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

12 2D Physics Overview Different Types of Colliders
* 2D Physics Overview Different Types of Colliders Rigidbody Collider – object with collider and Rigidbody Most common case Fully simulated by the physics engine Reacts to collisions Reacts to forces from script Collide with all other objects (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

13 2D Physics Overview Different Types of Colliders
* 2D Physics Overview Different Types of Colliders Kinematic Rigidbody Collider – object with collider and Kinematic Rigidbody Has “Is Kinematic” property set Does not react to collisions and forces from the engine Should be moved by a script They behave like static colliders but can be enabled/disabled/moved when needed (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

14 RigidBody 2D How to use it? *
(c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

15 RigidBody 2D Rigidbody 2D
* RigidBody 2D Rigidbody 2D Attach it to objects controlled by the physics In 2D only the XY plane takes effect for translation and the Z axis for rotation (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

16 RigidBody 2D Properties of RidigBody 2D Mass – mass of the object
* RigidBody 2D Properties of RidigBody 2D Mass – mass of the object Linear Drag / Angular Drag – coefficient for movements Gravity Scale – whether the gravity should be more or less on this object Fixed Angle – can be rotated or not? Is Kinematic – is the body moved by forces and collisions (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

17 Box Collider 2D How to use it? *
(c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

18 Box Collider 2D Box Collider 2D Rectangular shaped collider
* Box Collider 2D Box Collider 2D Rectangular shaped collider Attached to an game object With or without a sprite (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

19 Box Collider 2D Properties of Box Collider 2D
* Box Collider 2D Properties of Box Collider 2D Material – the material to use for the collider Is Trigger – whether events should be sent Offset – local offset of the collider geometry Size – the size of the rectangular shape (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

20 Circle Collider 2D How to use it? *
(c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

21 Circle Collider 2D Circle Collider 2D Circular shaped collider
* Circle Collider 2D Circle Collider 2D Circular shaped collider Attached to an game object With or without a sprite (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

22 Circle Collider 2D Properties of Circle Collider 2D
* Circle Collider 2D Properties of Circle Collider 2D Material – the material to use for the collider Is Trigger – whether events should be sent Offset – local offset of the collider geometry Radius – the radius of the circular shape (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

23 Polygon and Edge Colliders 2D
* Polygon and Edge Colliders 2D How to use them? (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

24 Polygon and Edge Colliders 2D
* Polygon and Edge Colliders 2D Polygon Collider 2D and Edge Collider 2D Complex shaped collider Attached to an game object With or without a sprite Difficult to compute – performance impact (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

25 * Circle Collider 2D Properties of Polygon Collider 2D and Circle Collider 2D Material – the material to use for the collider Is Trigger – whether events should be sent Offset – local offset of the collider geometry (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

26 * Forces How to use them? (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

27 Forces Two types of forces They both are added to a Rigidbody 2D
* Forces Two types of forces Constant Force 2D Effectors (Area Effector 2D for example) They both are added to a Rigidbody 2D Applied every Update of the game Good for in-game mechanics Have acceleration options (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

28 * Summary Rigidbody – component used by the physics engine for calculations Colliders – components to register any colliding objects in the game Different types of colliders – static, kinematic, etc. Other physics elements – joint, forces, etc. (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

29 2D Physics Engine

30 Free Trainings @ Telerik Academy
C# Telerik Academy csharpfundamentals.telerik.com Telerik Software Academy academy.telerik.com Telerik Facebook facebook.com/TelerikAcademy Telerik Software Academy Forums forums.academy.telerik.com


Download ppt "Done already for your convenience!"

Similar presentations


Ads by Google