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 |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