Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unity Overview Using Unity 3.5 (Free version) [1]:

Similar presentations


Presentation on theme: "Unity Overview Using Unity 3.5 (Free version) [1]:"— Presentation transcript:

1 Unity Overview Using Unity 3.5 (Free version) [1]: http://docs.unity3d.com/Documentation/ScriptReference/http://docs.unity3d.com/Documentation/ScriptReference/ [2]: http://docs.unity3d.com/Documentation/Components/index.htmlhttp://docs.unity3d.com/Documentation/Components/index.html [3]: http://wiki.unity3d.com/index.php?title=Head_First_into_Unity_with_JavaScri pt http://wiki.unity3d.com/index.php?title=Head_First_into_Unity_with_JavaScri pt

2 What is it? A Game Engine / IDE – A level editor – Management of Resources Meshes, lights, cameras, particle effects, … – Plugin (Component) architecture – Script support (JavaScript, C#, Boo) Versions: – Free (0$), Pro ($1500) Flash (+$1500), iOS (+$1500), Droid (+$1500), Team (+$500) – [Pro] NavMesh – [Pro] Audio Filtering – [Pro] Advanced pre-made shaders – [Team] SVN-like functionality – [iOS/Droid] Deploy to iOS/Droid devices (OpenGL ES?)

3 First step Create a new project – A new directory tree Assets – put your resources here Library, ProjectSettings, Temp A new.unity file – Each one is a "level" (group) Placement data for all level objects – Parameters for each Global settings – A binary (unfortunately) file in /Assets/ – Can have multiple "level's" at one time GUI / Menu "level", Level1-n (role of build settings)

4 Unity Player (IDE/Editor) overview TransformToolsPreview/Play Scene Inspector Hierarchy Project (Assets)

5 Add Resources & Instances Either – Save a resource in the Assets folder – Or drag-and-drop into the Project pane If you edit the resource, it's automatically updated in Unity – a great feature! Some supported resources –.blend (2.5+) : runs the fbx exporter –.fbx (maya, motionbuilder, …) – images – sounds – script files –…–… Drag it onto the scene (or hierarchy) to add to the hierarchy.

6 Scene Navigation [Alt+LDrag]: rotate camera [Alt+MDrag]: Pan camera [Alt+RDrag] or [Scroll]: Zoom [RClick] + WASDQE: – First-person camera mode – WASD to move – QE to go down/up [F]: Center the view around the selected game object [ArrowKeys]: Move on the XZ plane (ground) You can also use the buttons in the upper-left (SLOW!)

7 GameObjects A "thing" in the game – the current Level's ground – the player – enemies – health pickups – trigger point – …

8 GameObjects, cont. [Create an emtpy game object] Composed of components – Transform (a scene node) All GameObjects have this. Scale, Rotation, Translation… …from parent node The hierarchy pane is really a scene graph – Mesh Filter / Mesh Renderer – Physics Collider (capsule, box, mesh, …) RigidBody

9 GameObjects, cont. – ParticleEmitter – GUITexture / GUIText – AudioSource (2D or 3D, depending on asset) –…–… – Script (for anything else) Tags and Layers – Layers: Selective rendering, selective hit-detection A bitmask (32-bit integer) e.g. "Ground", "Post-processing" – Tag: Useful mainly in scripting Also a 32-bit integer A "group" (fast FindWithTag methods) e.g. "Main Camera", "Player", "Pickup", "Exit"

10 Prefabs A template for a commonly-used game object Assets=>Create=>Prefab – Drag an existing object from Hierarchy to new Prefab – Shows up in blue in Hierarchy – Drag more instances of Prefab onto scene – If you change the prefab definition, all instances will change too. You can modify the values of component attributes, but not the "structure" (e.g. components, although you can disable them) You can "break" the prefab connection by GameObject=>Break Prefab Instance.

11 Character Controller Import under Assets=>Import Package… Put a 3 rd person controller and camera on the player node – Drag the main camera transform onto the 3 rd person camera's "camera transform" property – Make sure the main camera is tagged with the "Main Camera" tag. [Later] A good example of a complicated script

12 Scripts (UnityScript) UnityScript is basically JavaScript Other choices: C#, Boo Assets=>Create=>JavaScript Double-click to go into MonoDevelop – Two functions add automatically: Start and Update – Example (in Update) transform.Rotate(0,5,0); Debug output – print("Hey!" + tempVar); – Display at bottom of window, or in the output window.

13 Scripts, cont. Variable declaration public var myVar [: myType] [= myVal]; public var direction : int = 99; – Other modifiers: static: visible to other scripts private: can't be modified in Inspector. Basic Types: int, float, string, boolean Enumerations: enum myEnum {state1, state2}; public var myState = myEnum.state1; Unity types: http://unity3d.com/support/documentation/ScriptReferen ce/20_class_hierarchy.html http://unity3d.com/support/documentation/ScriptReferen ce/20_class_hierarchy.html

14 Scripts, cont. Classes – Foo.js Creates a class named Foo Variables in Foo.js are members, functions are methods. – Other way: class MyRecord extends XYZ { public var name: integer; function doSomething() { /*…*/ } };

15 Scripts, cont. Public Variables are visible (and changeable) in the Inspector – A great feature! – [Demo] – Note: you can change them at runtime (but it's not permanent)

16 Classes, cont. Class must have same name as.js file (case-sensitive) To add a script to a GameObject, derive from MonoBehavior Constructor (function with same name as class) seems to be called: – before Start method is called – When (re-)entering Player (after pressing stop) You seem to be able to reference (other) scripts anywhere in the project.

17 Classes, cont. Some other important methods / functions to overload: – Full List: http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.html http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.html – LateUpdate: Called after all Update's – OnMouseEnter [GUIElement's] – OnCollisionEnter Called when this collider collides when another Note: one collider must have a non-kinematic rigidbody – OnCollisionStay –…–…

18 Accessing components The game object most likely has other components attached to it. E.g. You have a "Transform" component in Inspector – Access it in script like: "transform.position.x" – Note lower-case (this is the rule)

19 Messages Format GameObject.SendMessage(string, param); var go = GameObject.Find("Mine4087"); go.SendMessage("explode", 14.3); // (In any script(s) attached to Mine4087) function explode(timer : float) { // … } There is also a BroadcastMessage – Similar structure. Is sent to all child GameObjects recursively.

20 Scripting Misc. Time.deltaTime // Time since last Update. Application.LoadLevel(x) – x is an integer (see BuildSettings) or string – Removes all other objects, unless… DontDestroyOnLoad(gameObject); – Keeps it from being destroyed on LoadLevel call

21 GUI Made of GameObject's Add a GUILayer component to (a) camera. Make more components for each element – Make them children to the GUI layer component. Position: – (0,0,z): bottom-left – (1,1,z): top-right

22 Blender Review?

23 Character animations From Blender: – Keyframe the skeleton – Open a DopeSheet pane Select "Action Editor" from the drop-down Click "New" or "+" to add current keys to a new action. – The name you type will show up in Unity.


Download ppt "Unity Overview Using Unity 3.5 (Free version) [1]:"

Similar presentations


Ads by Google