UNITY | Project | RPG Tutorial |23. Loading

2
Copy Component
3
Paste Component as Value
4
Adding Music
5
Adding Scene
6
“MenuControl” Script
  • add UnityEngine.SceneManagement to use Scene Manager
  • create a function, NewGame(),
    • add SceneManager.LoadScene()
    • when this function is activated, the scene 0 is loaded
7
UI – Button | On Click()
8
UI – Button | On Click()
9
Play On Awake
10
Adding Loading Screen with UI-RawImage
11
“MenuControl” Script
  • in NewGame(),
    • when the function is activated,
      • stop the music
      • turn on the loading screen
12
Adding Script
13
Loading Screen
14
Turn off Loading Screen
AC_44
Loading Screen Working

UNITY | PROJECT | RPG Tutorial | 15. Debugging, Damage Taking, & Game Over

2-0
“Scene01” Script
  • FadeIn has never been turned off since it’s activated
3-1
UI – Button not Working
  • FadeIn is located on Canvas, where UI button is
  • with FadeIn on, the Buttons are under FadeIn (since FadeIn’s opacity is 0, we can’t see them)
  • the Buttons can’t be touched
2-2
“Scene01Skip” Script
  • create a script to turn off FadeIn 
3-2
UI-Text not Showing Up
3-0
“ChestTrigger” Script
  • even though we set the second UI Text shrinks automatically as soon as we open the chest, before shrinking the second UI Text was not activated.
    • there was nothing to shrink
46-e1536253559115.png
“ChestTrigger” Script
  • in Update() method, the local scale of UI-Text will be turned off when the localScale.y is less than 0
    • however, localScale is only set in Update() method.
    • there is no chance to access the localScale’s premier value
      • in Start() method,
        • set the localScale of UI-Text for Unity to access the value
5-1
UI-Working
5
“SpiderEnemy” Script
  • add SpiderAI as a component in the script
  • make spiderStatus variable as global by using static variable
  • spiderStatus = 0, means the spider is dead
    • when spider is dead, disable spiderAI script attached to Spider

setActive() vs enabled

setActive() turns off the gameObject

enabled turns off a component in the gameObject

6-1
Script Disabled
6
“SpiderAI” Script
  • create an int variable as an indicator for spider’s attacking
  • with another indicator, attackTrigger 1,
    • spider stops and the attack animation is player
    • IEnumerator TakingDamage() is played
  • create IEnumerator TakingDamage()
    • when an attack is done, set the indicator, dealDamage is set to 2
    • unless spider is dead,
      • Player’s health is taken by 1
    • wait for 0.5 sec
7
“HealthMonitor” Script
  • make this script reasonalbe
    • when Player has only one heart, turn off the second and third ones
    • when Player has two hearts, turn off the third one
8
GameOver Scene
9
GameOver Scene
  • create another scene, GameOver
  • add UI – RawImage for the black scren
  • add UI – Text for GameOver text
10
Build Setting
11
Build Setting
  • in Build Setting
    • add the first scene and the game over scene
    • pay attention to the scene numbers
2-1
“HealthMonitor” Script
  • when Player’s health  is 0, load the game over scene
13-1
Game Over Working

UNITY | PROJECT | 2D PlatFormer | 2. Camera & Death

2
“CameraSystem” Script
  • Create Variables for Player, and Camera’s Scope
  • in Start() method,
    • find player by using FindGameObjectwithTag()

 

3
“Main Camera”
4
“CameraSystem” Script
  • in LateUpdate() method,
    • create x & y variable for the position of Main Camera
      • Put the x & y values of Player in those x & y
      • Clamp the x & y with min & max values
        • Main Camera will move based on Player‘s Position
        • when Main Camera reaches at the position of Min or Max Values, Main Camera stops there
4-1
Main Camera following but clamped

 

5
Adding Box with Box Collider

 

6
Adding Ground2 with Box Collider
6-1
“Box”

 

2. Camera - Death
Creating “Hole” with “Box Collider”
8
Creating and Adding “PlayerHealth” Script

 

9
“PlayerHealth” Script
  • Create died bool variable as Flag
  • in Start() method,
    • Set the Flag as false
  • in Update() method,
    •  if Player‘s y position is below than -7,(Player falls down), show the log

 

9-1
Player Falling
10
PlayerHealth Script
  • Create a Coroutine
    • Create Die() as IEnumerator
    • Start the Coroutine with Die() by putting StartCoroutine() in Update() when Player died
    • don’t forget to put yield and return in IEnumerator
10-1
CoRoutine Working
11
“PlayerHealth” Script
  • change IEnumerator Die()
    • load the main scene when this IEnumerator is called by using SceneManager.LoadScene()
    • Don’t forget to yield return null
12
Scene Loaded well

UNITY TUTORIAL | PROJECT | SPACE SHOOTER |15. Ending Game

2
creating “Restart” UI Text
3
creating “Game Over” UI Text
4
adding codes to “GameController” script for Restart & GameOver
5
adding codes to “DestroyByContact”

ezgif.com-video-to-gif.gif