UNITY | Project | RPG Tutorial | 18. MiniMap Debugging, NPC Walking, & Saving Gold

2
“Quest001” Script
  • add a line of code to turn off MiniMap off when approaching enough
3
Updating Script

 

4-2
MiniMap Turned On
4
Updating ButtonManager
5
Adding NPC | Setting Default Animation
6
Measuring Vector3 with Cube
7
“NecromancerWalkAI” Script
  • create variables for
    • x, z position
    • where NPC head
  • in Start() method,
    • set X, Z values with Random.Range()
    • set the NPC’s transform.Position with a Vector3 with the X, and Z values
    • Start the Coroutine
  • in Update() method
    • make NPC keep looking at Cube(Destination) by using LookAt()
    • make NPC walk towards Cube(Destination) by using MoveTowards()
  • create IEnumerator RandomWalk()
    • wait for 5 seconds whenever creating changing the location of Cube(Destination) 
    • set X, Z values which we measured with Cube(Destination)
    • change the Cube(Destination)
    • get the Coroutine started in the Coroutine
      • automatically the Coroutine will be repeated

the logic is, make NPC  play “walk” animation, create a gameObject where NPC keep chasing, and make NPC walk towards it

8-1
NPC Walking

 

87.png
Adding Script
97.png
Creating RenderTexture for NPC Face
10
Adding Camera for NPC Face
116.png
Adding RenderTexture to Camera as Target Texture
124.png
Adding Render Texture to UI – RawImage
12-1
NPC Face Working

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