UNITY | PROJECT | RPG Tutorial |7.Triggers ,Weapons & Objectives

2
Making Clearing in Woods
3
Creating Collider as Trigger
4
“QuestTrigger” Script
  • create variables
    • the objective to configure
    • the flag to indicate we finish the objective
    • scale for the Objective
  • in Update() method,
    •  make if statement
      • change the locale scale of UI Text
      • make it disappear when the scale is 0
5
Adding Chest
5-1
Opening the top of Chest
6
Creating Animation for the top of Chest
7
Creating Animation with Transform.Rotation
8
Creating Animation with Transform,Rotation
8-1
Animtation Working
bandicam 2018-08-28 20-55-18-493
Adding “Animation” Component
9
Changing Setting in Dubug | Selecting “Legacy”
  • Since Animation Component is old one, to use it, we need to check Legacy option checked
12
Deselecting “Play Automatically”
12-1
10
Adding “Box Collider” as “Trigger”
13
Adding “Box Collider”
  • add Box Collider to prevent Player coming into Chest
14
Adding “Chest Trigger” Script to Trigger Collider
15
“ChestTrigger” Script
  • create Variable
    • for RayCasting to get the distance between Player and this Object itself
    • for Chest
    • for UIs
    • as a Flag to check whether we finish the obective
  • in Update() method,
    • get the distance
    • if the distance is lower than a specific value,
      • lower the scale of UI
      • make it disapear
  • in OnMouseDown() method,
    • when Cursor is on the object, and the distance is lower than a specific vlaue,
      • put the text into UI
      • make UIs appear
      • if Action button is pressed,
        • turn off the Box Collider
        • Play the animation of Chest
        • set the flag
        • turn off UIs
16
Adding Trigger & “Sword Trigger” Script
17
“Sword Trigger” script
  • create Variable
    • for RayCasting to get the distance between Player and this Object itself
    • for Sword
    • for UIs
    • as a Flag to check whether we finish the obective
  • in Update() method,
    • get the distance
    • if the distance is lower than a specific value,
      • lower the scale of UI
      • make it disapear
  • in OnMouseDown() method,
    • when Cursor is on the object, and the distance is lower than a specific vlaue,
      • put the text into UI
      • make UIs appear
      • if Action button is pressed,
        • turn off the Box Collider
        • Play the animation of Chest
        • set the flag
        • turn off UIs
17-1
Retriving Sword