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 |16. Quest Guiding Arrow

2
“QuestManager” Script
  • add variables for
    • number for subquest (static & internal path to use it in the other scritps)
    • pointer for quest guidance
  • in Update() method,
    • make the pointer keep looking at mainMark  by using LookAt()
    • if the quest number is changed to 1
      • make the pointer keep looking at mark for objective1
    • if the quest number is changed to 2
      • make the pointer keep looking at mark for objective2
    • if the quest number is changed to 3
      • make the pointer keep looking at mark for objective3
3
Creating Guidance Arrow
  • create Cube & Plain object
    • add textutre for the arrow
47.png
Texture | Shader
  • change the shader of the texture
    • Particles – Alpha Blended
      • to make the other part except the arrow transparent
5
Shader – Particle – Alpha Blended
6
Mesh Renderer Off
7
Equipped to Player
8-1
Guidance Arrow
8
Pointer
9
“QuestButton” Script | First Target in the Quest
10
“QuestTrigger” Script | Second Target in the Quest
114.png
“SwordTrigger” Script | Third Target in the Quest

 

12
“QuestComplete” Script | Fourth Target in the Quest
  • Track down each gameObject or Script considering the plot of Quest
  • when each object is done, notify QuestManger to go on the next step by updating QuestNumber
13
MainMark
  • create Main Mark from Cube
  • turn off renderer & collider
14-1
Pointer with Bug
15
“QuestTrigger” Script
  • since when Player goes back after obtaining the sword, QuestCollider is working againg
    • it updates the quest number, which we have finished alreay
  • turn off the collider when Player passes it

 

14
“QuestManager” Script
  • when Quest number is 0, turn off the pointer, or turn it on
15-1
Quest Guidance Working

UNITY | PROJECT | RPG Tutorial |14. Enemy AI

2
“SpiderAI” Script
  • create a variable for Player
  • in Update() method,
    • make Spider keep looking at Player by using transform.Lookat()
3
Adding Script
4
“SpiderAI”
  • create variables for
    • Player
    • distance obtained by RayCasting
    • distance where Enemy starts to move towards Player
    • Spider itself
    • speed of Spider
    • attack trigger to indicate when spider starts to attack
    • for RayCasting
  • in Update() method,
    • put the information from RayCasting to the RayCastingHit variable
    • put the distance from RayCasting into the variable for distance
    • if Player is within the minimum range of Spider,
      • set the speed of Spider
      • if attackTrigger is 0,
        • make Spider move with the animation, “walk”, toward Player by setting its tranform
    • if Player has left from the range of Spider,
      • set the speed of Spider into 0
      • make Spider idlen with the animation, “idle”
5-1
AI Working : Walking
5
Adding Script
6
“SpiderAI” Script
  • in Update() method,
    • add another if statement,
      • if attackTrigger is 1
        • set the speed of Spider into 0
        • make spider attack with animation, “attack”
  • in OntriggerEnter() method,
    • when spider touches somthing(Player), set attackTrigger into 1
  • in OntriggerExit() method,
    • when Player has escaped Spider, set attackTrigger into 0 to make it stop attack
7-2
AI Working : Attacking
7
Adding Collider
  • add Mesh Collider to Player
    • Convex, and is Trigger