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