Unity Game Development Creating an Interactive Character
Class overview Unity User Interface Lighting C# Variables Functions Code grouping Creating & adding scripts to GameObjects Time.deltaTime Rigidbody CharacterController Input Prefabs Audio & Importing Assets
Unity User Interface Creating 3D Objects Move, Rotate, Scale Inspector Window & Scene Hierarchy Adding components Creating Materials
2. Scene View 1. Scene Hierarchy 3. Inspector Window 5. Game View 4. Project Window
1. Tools 3. Application Actions 4. Active Axis 2. Selected Object Axis
Lighting Using lighting to create atmosphere (Omni light, Directional Light, ...)
C# Programming language developed by Microsoft Used for AI, Game logics, … Code in Microsoft Visual Studio Used in Unity3D
Variables name “John Doe” name string Variable: Something that stores information playerName health <variabletype> <variablename> = <variablevalue> Modifying a variable: “John Doe” name string
Functions Function / Method: A group of code that can run SaveGame DoDamage Functions execute code once each time the function is called Function body: Calling a function:
doubles <value> Functions void OnHit() void OnHit(int damage) Function just executes Function executes AND Needs Input int GetEnemyCount() int DoubleValue(int value) Function executes AND Function executes AND returns value needs input Code inside the function reduces health by <damage> Code inside the function reduces health int int Searches the map for enemies and returns the # Code inside the function doubles <value> and returns it int int
Code Grouping In C#, all code is grouped, and sub-grouped. For this we use curly brackets. { = opening curly bracket } = closing curly bracket MyGame Program MyFunction MyOtherFunction
Creating & adding scripts to Game Objects Start, Update (+ Awake, FixedUpdate, ...) OnTriggerEnter, OnTriggerExit Instantiating & Destroying GameObjects from scripts Accessing variables from the Editor (public, private, serializable)
Time.deltaTime Time.deltaTime = time between updates Update() has a variableTime.deltaTime FixedUpdate() has a fixed Time.deltaTime 5 FPS = 5 Frames per Second 60 FPS = 60 Frames per Second
Rigidbody Collisions & Triggers Physics using Rigidbody & AddForce OnTriggerEnter and OnTriggerExit
Character Controller Using a Character Controller to control and move a character
Input Detecting PlayerInput (Mouse movement and Key presses)
Jumping logics Applying gravity constantly vs. Applying gravity at a variable intensity
Prefabs Creating assets for instancing and updating scene
Audio & importing custom assets Playing sounds / Music using AudioSource and AudioClips
Q&A Do you have any questions related to the topics mentioned?