UNITY | PROJECT | RPG Tutorial |5. RayCasting

2
Creating “PlayerCasting” script
3
“PlayerCasting” script
  • creating a static variable for the distance of RayCasting
    • create another variable as a internal path for the static variable
  • in Update() method,
    • imply a RayCasting from the mission board, with the direction of forward
    • with out keyword, put the information of RayCasting into hit variable
    • put the distance between the mission board and player in toTarget
    • connect the static variable and the path variable
3-1
RayCasting Working
4
Creating Text UI for indicating Key
5
Creating Text UI for indicating Action
6
InputManager | Adding a button
7
Adding a quest note with Plane
8
“Quest001” Script
  • creating Variables
  • in Update() method,
    • put the distance from the RayCasting in PlayerCasting Class  into “distance
      • for this, distanceFromTarget is set as Static
  • in OnMouseOver() method,
    • if the distance of RayCasting is less than 3,
      • set ActionButton and ActionText active
      • if Action button is pressed,
        • set actionButton, ActionText, and Player inactive
        • set UIQuest and Notice Camera active
  • in OnMouseExit() method,
    • set actionButton and actionText inactive
10
Adding RawImage UI | Making Notice UI for Quest
11
Setting Components off as default value
12
Notice Camera for the Quest
13
Making a Trigger with Cube
14
Making a Trigger with Cube
  • Be careful with the position of Triggers
  • If it’s buried in the other objects like the notice board, it is not detected by RayCasting
15
Put Components in the script
15-1
RayCasting Working
15-2
Action Working

UNITY | PROJECT | RPG Tutorial |3. HUD, UI, & Environment(Water)

2-0
Making the soil a little higher
2-1
Smoothing the soil
2-2
Lower the soil a little for water to flow
3-0
Creating Water
  • import water from Unity Standard Asset
  • Water is just an object concrete
3-1
Modifying Water
4-0
Water Modified
4-1
Water
5
Adding another Tree
68.png
Tree
7
UI – RawImage
  • add UI – RawImage
    • The Raw Image control displays a non-interactive image to the user
    • Since the Raw Image does not require a sprite texture, you can use it to display any texture available to the Unity player
8-0
Canvas | Screen through Camera
  • the white line means our monitor’s screen

 

8-1
Rawimage working
9
RawImage | Anch
  • PosX & PosY means the RawImage is apart from the anchor(Top-Left) by 75
10
Adding Heart Texture to RawImage
11
Creating a blank space for Heart
12
Blank Heart Anchored Top-Left
13
Heart Anchored Center | Child Object of Blank Heart
  • Since ViewHearts are Child Object of Heart, their position is based on the Heart’s
14
Making Heart Indicator by Duplicating
15
“HeartMonitor” Script
  • Create Variables
    • to use in another script make heartValue as Static
    • internalHeart is to be used as a path to heartValue
    • to use Heart, Create GameObject as a vessel
  • in Update() method,
    • create if statement, making Heart Active, whenever Player collects one
16
“Heathcollects” Scritp
17-0
Creating HealthMonitor from Empty GameObject | Adding Hearts to Script
17-1
Collecting Heart & HeartMonitor Working
18-0
“HeartMonitor” Script
  • in Start() method
    • set the initial value of heartValue as 1

 

 

18-1
Collecting Hearts

 

“when Unity says, “There are 2 audio lister”, remove main camera if you are using FPS Character”

UNITY | PROJECT | SPACE SHOOTER 2D | 8. Lives UI, Play Button, & Game Manager

2
Importing UI Sprites
3
Adding UI Image
  • Adding UI Image for Score & Lives

 

4

  • Adding Sprite to UI Image as “Source Image”

 

5
UI Image Applied

 

6
UI Anchor

 

7.1
Adding & Configuring Sprite to UI Image for Scores UI
  • Adding Sprite to UI Image as “Source Image”

 

7.2
UI Anchor

 

8
Creating UI Text
  • Creating UI Text to count Player’s Life

 

9
Adding & Configuring UI Text to Image UI
  • In UI Text
    • set the default Text as “0”
    • change Font Style & Size
108-e1531887916889.png
UI Anchor

 

11
Creating UI Button
  • Create UI Button for Play Button

 

12

13

14
Adding Sprite to UI Button
  • In UI Button
    • Set the size
    • Add Sprites for “Target Graphic”(usual) & “Pressed Sprite”(pressed)

 

15
UI Anchor

 

16
Creating “GameManager” Script
17
Adding Reference
181.png
“GameManager” Script
  • To control PlayButton&Player with GameManager
    • create Public Object as a Reference
    • create an Enumeration, “GameManagerState” to tell Game State
      • Opening, GamePlay, and GameOver
    • create a Function, “UpdateGameManagerState()”
      • use “Switch Statement”
        • make 3 cases

 

19.1
“Play Button”
  • now, Play Button reacts to Clicking but nothing happens

 

19.2
“PlayerControl” Script
스크린샷 2018-07-18 오전 2.21.17
“Player”
20.1
“PlayerControl” Script
ec8aa4ed81aceba6b0ec83b7-2018-07-18-ec98a4eca084-1-22-31.png
“PlayerControl” Script
  • create “GameManager” GameObject as a reference
  • set “Player” inactive for the first moment of Game
  • In “Init()” method, which is called when Game Starts
    • set the current life(“lives”) as MaxLife
    • update UIText by using Text.text property
    • change the number(int “lives”) to string by using int.Tostring() method
    • set Player active when Game starts
  • In “OnTriggerEnter2D()” method(when a Collision with Player happens,)
    • the life is subtracted
    • when the life is 0,
      • use “SetManagerState” in “GameManager” Class with “GameOver”()*(putting the name of “enum”)
      • hide Player GameObject by set it “false”

 

8. Live UI, Play Button, - GameManager
“GameManager” Script
  • update “GameManager” Script
    • in “Start()” method
      • set “GMState” in “Opening”
    • in “UpdateGameManagerState()”
      • in case of “GamePlay”,
        • Set “PlayButton” active to hide it when Game Starts
        • Activate “Init()” method
    • Create” SetGameMangerState()” method to change the Game’s State, having “GameManagerState”(enum) as Parameter
    • in “StartGamePlay()” method
      • change “GMState” into “GamePlay”
      • Don’t forget to put “UpdateGameManagerState()”

 

 

21
“PlayButton” | Sprite & “On Click()”

 

  • In Play Button,
    • Add Sprite for “Target Graphics”(Usual) and “Pressed Sprite”(Pressed)
    • Add “On Click()” event and designate it “StartGamePlay()” method in “GameManager” Class
    • with this part, No Need to write to Star Game

 

231-e1531888420395.png
Adding Reference
ezgif.com-video-to-gif
“PlayButton” & “PlayerLife” working
26
“GameOver” Image added
  • Add “GameOver” Sprite
    • add the sprite to GameManager
    • add the Sprite to the scene
27
GameOver “Off”
  • Turn off “GameOver” for it to be hidden in the first moment of Game

 

28
“EnemySpawner” Script
  • Create a Function, “UnscheduleEnemySpawner()”, to stop the spawning when the game is over” by using “CancelInvoke()”

 

29
“GameManager” Script
  • Create “ChangeToOpeningState()” method
    • use “SetGameMangerState()” method
  • In Case of “GameOver”,
    • put “UnscheludeEnemySpawner()” method to stop the spanwing
  • In Case of “Opening”
    • turn off “GameOver” by using “GameObject.Setactive()”
30
Adding Reference
ezgif.com-video-to-gif
Game Working

 

UNITY TUTORIAL | PROJECT | SPACE SHOOTER |14. Counting Points and Score

2
Creating Canvas & UI Text
3
Changing “Anchor” of UI Text
4
Changing “Anchor” to “Top-Left”
11
adding codes to “Game Controller” script
12
adding Text UI to “Game Controller” script as a reference
13
Adding Codes to “DestroyByContact” script | making a reference of “Game Controller” to use “AddScore” Function
14
setting Score Value in Asteroid Prefab
5
Creating “Game Score” Script

ezgif.com-video-to-gif-2

Another way of setting Score UI

6
Game Score Script
7
Adding “Game Score” script to Text UI
8
Tagging UI
9
adding codes to increment score after destroying a hazard

 

UNITY TUTORIAL | PROJECT | Roll a Ball | 6. Collecting the Pick Up Object

Roll a Ball

Collecting the Pick Up Object

2
OnTriggerEnter() | CompareTag() | SetActive()
3
Add Tag
4
Add Tag
5
Add Tag
6
Apply Tag
7
Appy Tag
ezgif.com-video-to-gif.gif
SetActive not working
9
selcting
10
Unity’s Physics Engine | Static Collider | Dynamic Collider | Trigger | Trigger Collider
11
Collier | Trigger
12
Collier | Trigger

ezgif.com-video-to-gif (1)

13

14
RigidBody | Collider | Dynamic
15
Prefab | RigidBody | came to Dynamic
ezgif.com-video-to-gif (2)
RigidBody | Gravity
163.png
RigidBody | Gravity | Partial Solution
17
RigidBody | Gravity | Kinematic
ezgif.com-video-to-gif (3)
Gravity Overcome

 

18
Creating Variable as Reference
19
Creating UI Text

20

21
Chaing Position of UI
22
Configuring
23
NameSpace | UnityEngine.UI
24
Text.text | ToString
25
Custom Method to make the script shorter
26
Private Variable

 

ezgif.com-video-to-gif (1).gif
Text UI

 

27
Creating Win Text
28
changing​ the location of UI Text
29
Using Custom Method
30
Custom Variable
31
Private Variable
ezgif.com-video-to-gif (2)
UI Text