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

UNITY | PROJECT | RPG Tutorial |10. Cut Scenes

2
Creating “FadeIn”
  • create FadeIn  from UI – RawImage
  • set Anchor into Stretched
3
Creating Anmaition
4
Creating Animation
5
Creating Animation
6
Creating Animation
  • create Animation
    • in 0th frame, set the opacity to 1(255)
    • in 60th frame, set the opacity to 0(0)
  • add Animation Component
    • turn on Legacy
    • set Wrap Mode into Once
5-1
FadeIn Working
7
Creating Scene Camera
8
Creating Scene Camera
9.png
Creating Scene Camera
10
Creating Scene Camera
11
Creating Scene Camera
12
Creating Scene Camera
13.png
Creating Scene Camera
14
Creating Scene Camera
15
Creating Scene Camera
16
Creating Scene Camera

17

18.png
Creating Scene Camera
  • add Scene Cameras
    • add Animations to each Camera by changing Transform.Position or Transform.Rotation for 5 sec(300 frames)
  • add Animation Component
    • turn on Legacy
    • set Wrap Mode into Once
  • turn Camera2  and Camera3
19
Creating “FadeOut”
20
Creating “FadeOut”
21
Creating “FadeOut”
22
Creating “FadeOut”
23
Creating “FadeOut”

24

25
Adding BGM
26
Creating Scene Object
  • add Scene01  from Empty GameObject
10. Cut Scenes
“Scene01” Script
  • create Variables for Gameobjects
  • in Start() method,
    • get the Coroutine started by using StartCoroutine() for the coroutine start from the first frame
  • create IEnumerator
    • automatically, in the first frame, FadeIn and Camera1 starts
    • wait for specific time considering the duration of each Animation
    • for the last moment, turn on Player
26-1
Cut Scene Working
2
Adding Place Name with UI Text
2-1
UI Working

 

 

UNITY | PROJECT | RPG Tutorial |9. Weapon Animation

2
Creating Animation for Sword
316.png
Creating Animation for Sword
4
Creating Animation for Sword
  • create an Animation
    • by changing Transform(Position & Rotation) however I want
    • for each frame we can add changes
4-1
Creating Animation for Sword

 

5
“Animation” Component
  • Remove Animator(New)
  • Add Animation(Legacy)
    • Put the Animation for Sword in Animation Component as Animation & Element0
    • Since we have one animation, Set Size into 1
6
“Animation” | Legacy
  • in Animation Component,
    • in Debug tap, check Legacy
7
Animation | Wrap Mode | Once
  • to make Animation play once, change Wrap Mode into Once
8
InputManager | Key “Fire1” for Left Mouse Button
9
“SwingSword” Script
  • create Variables
    • for Sword we are yielding
    • for the status of sword
10-1
Animation Working
10
Adding Script to Sword
11
“AttackBlocker” Script
  • create a script to prevent Player from Yielding Sword in specific conditions
  • create variables one static and the other as path
  • in Update() method
    • put the static variable in the path variable
12
Adding “AttackBlocker” into “GlobalStat”
13
“Quest001” Script
  • add AttackBlocker.blockSword to Quest001 to change the status of swinging Sword
    • in OnMouseExit() method,
      • set the status as 0, indicating Swinging is available
    • in OnMouseOver() method,
      • when Action Button is pressed,
        • set the status as 2(actually 1), indicating Swinging is not available when grabbing the Notice
      • when Distance is less than 3,
        • set the status as 2(actually 1), indicating Swinging is not available when standing in front of the Notice Board
14
“SwingSword” Script
  • Add AttackBlocker.blockSword ==0 to the condition of if statement
14-1
Swinging Sword is not working

 

UNITY | PROJECT | RPG Tutorial |6. UI Buttons

2
Adding UI – Panel
3
Adding UI-Text
4
Adding Aceept Button |  UI-Button
5
Adding Font
6
Adding Font
7
Adding Decline Button
7-1
Buttons Working
8
Adding Quest Infromation | UI-Text
9
Creating Animation | Animation Tap
11
Creating Animation | Animation Tap
12
Creating Animation | Animation Tap
13
Creating Animation | Animation Tap
14
Crating Animation | Animation Tap
  • for the Quest Information UIs to appear with Animation, Create an Animation
    • For 0s, 60s, 6s, and 8s, change the Alpha value
10
Animation | Loop Time.
  • Animation Created
  • Deselect Loop time to prevent UI from appearing continously
15
Duplicating UI
202.png
“QuestManager” Script
  • create a script for Quests
  • create a static variable to use it in the other script(class)
  • create another variable a path for the static variable
  • in Update() method,
    • update the quest number
16
“Quest001 Buttons” script
  • create GameObjects variable as references
  • create a function, AcceptQuest(),
    • make Player and noticeCamera Active
    • make UI QuestLabel Inactive
    • start a Coroutine, SetQuestUI()
  • Create an IEnumerator()
    • put texts in the UIs
      • UI has Text component in itself
      • Getcomponent<>().text means accessing the text component
      • make UIs appear in order by using Coroutine
      • finally, make the UIs disappear
17
Creating QuestButtonManager from Empty GameObject
18
Setting Quest UIs off

18-1

19
Setting Acting for Button
  • in Accept Button,
    • add QuestButtonManager into On Click()
    • set the Action by accessing Quest001Button script
21
“Quest001” Script
  • for the mouse cursor to appear
    • add Screen.lockCursor
    • add Cursor.visible

UNITY | PROJECT | 2D PlatFormer | 2. Camera & Death

2
“CameraSystem” Script
  • Create Variables for Player, and Camera’s Scope
  • in Start() method,
    • find player by using FindGameObjectwithTag()

 

3
“Main Camera”
4
“CameraSystem” Script
  • in LateUpdate() method,
    • create x & y variable for the position of Main Camera
      • Put the x & y values of Player in those x & y
      • Clamp the x & y with min & max values
        • Main Camera will move based on Player‘s Position
        • when Main Camera reaches at the position of Min or Max Values, Main Camera stops there
4-1
Main Camera following but clamped

 

5
Adding Box with Box Collider

 

6
Adding Ground2 with Box Collider
6-1
“Box”

 

2. Camera - Death
Creating “Hole” with “Box Collider”
8
Creating and Adding “PlayerHealth” Script

 

9
“PlayerHealth” Script
  • Create died bool variable as Flag
  • in Start() method,
    • Set the Flag as false
  • in Update() method,
    •  if Player‘s y position is below than -7,(Player falls down), show the log

 

9-1
Player Falling
10
PlayerHealth Script
  • Create a Coroutine
    • Create Die() as IEnumerator
    • Start the Coroutine with Die() by putting StartCoroutine() in Update() when Player died
    • don’t forget to put yield and return in IEnumerator
10-1
CoRoutine Working
11
“PlayerHealth” Script
  • change IEnumerator Die()
    • load the main scene when this IEnumerator is called by using SceneManager.LoadScene()
    • Don’t forget to yield return null
12
Scene Loaded well