“Scene01” Script
- FadeIn has never been turned off since it’s activated
UI – Button not Working
- FadeIn is located on Canvas, where UI button is
- with FadeIn on, the Buttons are under FadeIn (since FadeIn’s opacity is 0, we can’t see them)
- the Buttons can’t be touched
“Scene01Skip” Script
- create a script to turn off FadeIn
UI-Text not Showing Up
“ChestTrigger” Script
- even though we set the second UI Text shrinks automatically as soon as we open the chest, before shrinking the second UI Text was not activated.
- there was nothing to shrink
“ChestTrigger” Script
- in Update() method, the local scale of UI-Text will be turned off when the localScale.y is less than 0
- however, localScale is only set in Update() method.
- there is no chance to access the localScale’s premier value
- in Start() method,
- set the localScale of UI-Text for Unity to access the value
UI-Working
“SpiderEnemy” Script
- add SpiderAI as a component in the script
- make spiderStatus variable as global by using static variable
- spiderStatus = 0, means the spider is dead
- when spider is dead, disable spiderAI script attached to Spider
setActive() vs enabled
setActive() turns off the gameObject
enabled turns off a component in the gameObject
Script Disabled
“SpiderAI” Script
- create an int variable as an indicator for spider’s attacking
- with another indicator, attackTrigger 1,
- spider stops and the attack animation is player
- IEnumerator TakingDamage() is played
- create IEnumerator TakingDamage()
- when an attack is done, set the indicator, dealDamage is set to 2
- unless spider is dead,
- Player’s health is taken by 1
- wait for 0.5 sec
“HealthMonitor” Script
- make this script reasonalbe
- when Player has only one heart, turn off the second and third ones
- when Player has two hearts, turn off the third one
GameOver Scene
GameOver Scene
- create another scene, GameOver
- add UI – RawImage for the black scren
- add UI – Text for GameOver text
Build Setting
Build Setting
- in Build Setting
- add the first scene and the game over scene
- pay attention to the scene numbers
“HealthMonitor” Script
- when Player’s health is 0, load the game over scene
Game Over Working