UNITY | Project | RPG Tutorial |22. Main Menu

2
New Scene | Plane
3
Creating Texture
4
Creating Plane | Adding Texture
  • create 2 planes as the background of Main Menu
  • make them stand towards Main Camera
5
Adding Logo to Plane | Shader
6
Texture Created Automatically
  • add logo image
  • after adding an image to Shader, the material is created automatically
7
Child Object
8
Rotating BackGround
  • rotate the background a little for the scene not to be seen though the logo
9
Lighting | Sky Box
10
Adding UI Text
11
Effects – Particle system
12
Adding Particle System
13
Creating UI Buttons
14
Creating Side Bar with UI Button
15
Side Bar
16
Creating UI Button
17
Creating Animation for Sliding Bar
18
Adding Animation
19
Animaiton | Wrap Mode
  • create a UI Button covering all the screen, but invisible
    • for “click anywhere to start”
20
“MenuControl” Script
  • create variables
    • for the empty gameObject, “menuSlider”
  • create a function, SlideMenu(),
    • when the function is activated, play the menu sliding animation

 

21
Adding Script
22
UI Button | On Click() | Adding Function
23
“MenuControl” Script
  • add variables,
    • for UIs to disappear after Side Menu appear
AC_28
Main Menu Working

UNITY | Project | RPG Tutorial | 19. NavMesh & Boss AI

2
“NPC001” Script
  • when Player finishes the first Quest, change the saying of NPC by changing QuestNumber in QuestManager
3
Adding Trigger for Gate
  • Adding Cube for Trigger for opening Gate
4
“Quest002Start”
  • creating variables
    • for distance between Player and NPC
    • UI – Buttons
  • in Update() method,
    • getting the distance by using PlayerCasting
  • in OnMouseOver() method,
    • if Player is close enough to NPC
      • prevent Player from attacking
      • set the UI Text with messeges for Gate
      • if Action Button pressed
        • allow Player to attack
        • allow Player to use
        • turn off UI Text
ezgif.com-optimize.gif
NPC saying Different
5
Adding Cube as Walkable Ground
  • add Cube as a boundary for the boss to walk
6
Windows – AI – Navigation
7
Navigation | Walkable
8
Naviagtion | Bake
9
Turning off Mesh Renderer
10
NavMesh Agent
11
“SpiderBossAI”
  • create variables
    • where spider boss goes
    • NavMeshAgent
  • in Start() method,
    • make the NavMeshAgent variable NavMeshAgent
  • in Update() method,
    • through the NavMeshAgent variable, set where the boss to go
12
Adding Script
13
Animation
14
Animation | WrapMode
15
Creating Barriers
16
Barriers | Navigation | Non Walakble
17
Barriers | Bake | Bake
  • to prevent the boss from walking through the barriers, bake the barriers Non Walkable
18
SpiderBoss | NavMesh Agent | Radious like Collider
18-1
SpiderBoss Moving
19
Adding Cube as Trigger
  • put Spider Boss in a Cube Object named SpiderBossTrigger as child object
18-2
SpiderBoss Following Player
20
Adding Attack Animation
21
“SpiderBossAttack” Script
  • create variables
    • spider boss itself
    • as flag for attacking
  • in Update() method,
    • if attackTrigger is 0
      • make the boss walk with the animation
    • if attackTrigger is 0
      • if dealDamage  is 0
        • get the boss attack by player the animation
        • get the coroutine TakingDamage started
  • create IEnumerator TakingDamage()
    • set dealDamage into 2
    • wait for 1.1 sec
    • if spider’s status is not dead
      • get rid of one heart of Player
    • wait for 0.5 sec
    • set dealDamage into 0
  • in OnTriggerEnter() method,
    • when the boss touches Player, set attackTrigger into 1
  • in OnTriggerExit() method,
    • when Player gets out of the boss, set attackTrigger into 0
22
Adding Script
  • Adding Script
  • put SpiderBoss in the script
22-1
Spider Boss Following & Attacking Player

UNITY | PROJECT | RPG Project |17.Mini Map, SkyBox, & Money Saving

2
Creating MiniMap
3
Creating MiniMap
  • Create MiniMap by using UI-RawImage
49.png
Adding Camera to MiniMap
5
Creating “RenderTexture”
6
Adding Texture to MiniMap
  • the result image from Camera to RenderTexture by adding it to Target Texture
  • add the RenderTexture to MiniMap
7-1
MiniMap Working
7
Add Pointer on MiniMap
8
Windows – Rendering – Lighting Settings
96-e1536540831896.png
Adding SkyBox
11
SkyBox Applied

12

13
UI for Gold
142.png
“GloblaCash” Script
  • create variables for
    • gold as static
    • gold as internal path
    • UI
  • in Update() method,
    • making Gold variables global
    • put the gold information to UI
15
“QuestComplete” Script
  • add a line of code to get 100 gold when completing quest
15-1
Obtaining Gold
17
“SaveGold” Script
  • in Start() method,
    • make this script load the amount of gold saved when the games starts by using PlayerPrefs.GetInt()
16
“QuestComplete” Script
  • after obtaining gold, update the save file for gold by using PlayerPrefs.SetInt()

181.png

AC_12
Gold Loading Working
  • after Quest complete, when we start the game again, the gold obtained last time is saved in SaveGold

 

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 | RPG Tutorial |13. NPC

2
Adding NPC
3
NPC Idling
3
Adding collider
4
Adding “Text Box” from UI – Panel
  • set the anchor into stretch
5
Adding UI – Text for NPC Name
6
Adding UI – Text for NPC Saying
7
Adding UI-Raw Image for NPC Picture
8
Turning off TextBox
93-e1536078456298.png
“NPC001” Script
  • in Update() method,
    • put the Raycasting to get the distance from NPC to Player
  • in OnMouseOver() method,
    • if the distance between NPC and Player,
      • set the status of Player’s Sword into 1, unable to attack
      • show the message through UI Text
      • if Action Button is pressed,
        • set the status of Player’s Sword into 2, unable to attack
        • show Mouse Cursor
        • turn off the first UI Texts
        • get the Coroutine started
  • in IEnumerator NPC001Active()
    • show Text UIs for NPC talking
    • wait for 5 sec
    • turn off the UIs for NPC talking
    • show the first UI Texts
  • in OnMouseExit(),
    • set the status of Player’s Sword into 0, able to attack
    • turn off the first UI texts

 

10
Adding Script | Adding Components
11-1
Interacting with NPC