Presentation is loading. Please wait.

Presentation is loading. Please wait.

Angry Teapots– using the physics engine in Unity Peter Passmore.

Similar presentations


Presentation on theme: "Angry Teapots– using the physics engine in Unity Peter Passmore."— Presentation transcript:

1 Angry Teapots– using the physics engine in Unity Peter Passmore

2 What is Unity and what can I do with it? Unity is a fully integrated development engine that provides rich out-of-the-box functionality to create games and other interactive 3D content. You use Unity to assemble your art and assets into scenes and environments; add physics; simultaneously play test and edit your game, and when ready, publish to your chosen platforms, such as desktop computers, the Web, iOS, Android, Wii, PS3 and Xbox 360. Unity’s complete toolset, intuitive workspace and rapid, productive workflows help users to drastically reduce the time, effort and cost of making games.

3 Play some unity demos http://unity3d.com/gallery/demos/live-demos

4 Angry birds With a combined 1.7 billion downloads across all platforms and including both regular and special editions

5 Temple Run Temple Run 2 - Temple Run 2 Fastest Downloaded Mobile Game Ever, 50 Million Copies in Two Weeks (Thursday January 31, 2013) The previous fastest downloaded game was Angry Birds Space, selling 50 million copies in under six weeks http://www.youtube.com/watch?v=qPMIQo bB3ZM http://www.youtube.com/watch?v=qPMIQo bB3ZM

6 Critical Incident management training System using an Interactive Simulation environment PI: Prof William Wong, led by Middlesex University with 12 partners across 7 countries with ~€3.5M EU funding

7 Crisis

8 What do you need to make a 3D game?

9 3D objects – Geometry – Textures – Animation – Physics – Collision detection Lights Camera

10 Unity concepts Assets Scenes Game objects Components Scripts Prefabs

11 Unity Interface (windows|layouts|2 by 3)

12 Unity interface Scene – where game is constructed (set) Hierarchy – list of GameObjects used in the scene Inspector – settings for the currently selected asset/object e.g. its position scale Game – the preview window, where you actually play the game Project – a list of your assets (images, sounds etc)

13 The scene window The Hand tool – Pans the scene window. – If you hold down ALT it rotates the scene – If you hold down CTRL it zooms the scene The Translate tool – you can move you currently selected object along each of its axes The Rotate tool – rotate your object around each of the 3 axes The Scale tool - scale your object along each of the 3 axes – Drag on the central box to scale uniformly

14 Create two cubes Choose GameObject|Create Other|Cube to create a cube and set its postion and rotation as shown Choose GameObject|Create Other|Cube to create another cube, move it down Scale it to make a floor plane, name it Floor

15 Apply physics to the box Select cube Choose Components|Physics|RigidBody (note that gravity ticked in Inspector) Play animation (box falls and collides) Choose Assets|Import Package|Physic Materials click on All in the popup window Then select box1, in the Inspector under Box Collider click on small circle to the right next to Material – then Choose Bouncy When you play the game now the box bounces a lot

16 Note Bouncy in Box collider in the Inspector

17 Create a sphere Choose GameObject|Create Other|Sphere to create a sphere Make it a Rigid Body and Bouncy like the box Set its position manually by clicking on the sphere and typing in to the inspector setting its position

18 Light Choose GameObject|Create Other|Directional light Set its rotation as you like Move the view in the scene window until you can see everything well Select the Main Camera in the Hierarchy and choose GameObject|Align With View to use the same view for the game

19 Set shadows Select the Directional light and in the inspector turn on shadows by setting Shadow Type to Soft Shadows

20 E.g. I had this for Main Camera Transform With this scene view: See scene 1

21 Add colour (optional) Choose Assets|Create|Material A new material appears in the asset tab. Rename it by typing red Then in the Inspector window click on the white box next to main color, and a color picker box will appear, click on red

22 Add color (optional) Now drag the red material from the Assets tab and drop it on the sphere in the main window, the sphere now shows red Make two other colours for the floor and cube

23 Add texture – Basket ball Choose Assets|Import New Asset and navigate to basketBallTexture.jpg (in the assets folder) In the project window you will see the new texture as a Material Drag and drop this material onto the sphere to turn it into a basket ball

24 Add texture – cube and floor Now do the same for the cube using the texture called redPlasic.jpg Now do the same for the floor using the texture “Grass 02 seemless” In the inspector window set the tiling values for X and Y to 10 to get the texture down to a reasonable size.

25 Textured scene See scene3

26 Reset cube and sphere Transforms and view Reset cube transform to: Res t sphere transform to Change the view to so you can see the sphere and cube:

27 Write a script Right Click below the word Assets in the assets window and click on Create on the popup menu and then on Javascript A new document icon appears called New Behaviour, just type push and the document is now titles push Double click to edit the script After some time a window appears called mono editor

28

29 Edit the script so that it looks as follows:

30 Apply the script to the Sphere Save the script by choosing File|Save Now drag the push icon from the Assets window and drop it on the Sphere in the Hierarchy window The word sphere in the Hierarchy window will briefly show and blue line around Now if you click on the Sphere you will see that the script is attached to it at the bottom of the Inspector window

31 Script Click on the sphere and in the inspector window in crease the vale of powerZ until the ball hits the cube (e.g. 850) See Scene4

32 Collision! Now when you run Unity you will see that the – force is immediately applied to the sphere – and that it collides with the box and – both the box and the sphere behave like physical objects according to Newtons laws of motion. Click on the sphere in the Hierarchy window and then change the value of Powerz in the push Script section of the Inspector window to -500. Explain what happens when you run the program.

33 Get a teapot In this case I import teapot from a 3D modelling package call 3D studio MAX You can find many 3d models on the net ALL you do is choose Assets|Import New Asset Then you new asset will appear in the assets tab And you can drag and drop it into the scene

34 Make the teapot angry!

35 Put the teapot in the scene Choose Assets|Import New Asset to import a the teapot into the scene. Set its transform to place it on the cube: Select the sphere and in the inspector set the value of PowerZ to 900 so the ball hits the teapot See scene 5

36 Add Skybox Choose Assets|ImportPackage|Skyboxes then click import in the popup window Choose Edit |Render Settings Next to Skybox Material in the Inspector tab on the right there is a small circle with a dot in the middle. Click this and it brings up the Select Material window. Choose Sunny 1 you now have a semi cloudy sky

37 Ball and teapot collide See scene 6

38 Step up time - optional Choose Edit|Project Settings |Time and change Time Scale eg from 1 to e.g. 4 You may have to change the values of forces after this (eg in the push script)

39 Make two mesh collider objects collide Select the teapot in the Hierarchy window Right click and chose duplicate and a copy is made in the exact same position as the existing one. Move it up to see it. If you run the program the two teapot pass through each other To fix this problem tick the Convex flag in the mesh collider section of either teapot (this is supposed to only work for object of 256 or less polygons)

40 All these steps are in the tutorial project on your computer Now build your own game/simulation!


Download ppt "Angry Teapots– using the physics engine in Unity Peter Passmore."

Similar presentations


Ads by Google