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