UNITY | PROJECT | SPACE SHOOTER 2D | 4. Enemy Animation & Enemy Spawner

2
Creating Enemy Animation
  • by selecting multiple Sprites and adding them in the scene, Create “EnemyAnimation”

 

3
Changing the name of EnemyAnimationController

 

4.1
“Enemy” GameObject

 

4.2
“Enemy” GameObject with Animation

 

5
Adding “EnemyControl” Script to “Enemy” GameObject

 

6.1
“EnemyControl” Script
  • Set the speed of Enemy with a float variable “speed”
  • in “Update()” method
    • change the position of “enemy” GameObject with “transform.position” every frame
    • for memory usage, destroy “enemy” when it goes out of the screen

 

6.2
“Enemy” Moving

 

6.3
“Enemy” Destroyed when outside of the screen

 

7
Creating “Enemy” Prefab

 

8
Creating “EnemySpawner” & Adding “EnemySpawner” Script
  • Create Empty GameObject and change its name into “EnemySpawner”
  • Create “EnemySpawner” Script and add it to “EnemySpawner”

 

9.1
“EnemySpawner” Script
  • To use “Enemy Prefab” in the script as a component
    • add “Public GameObject” variable
    • Don’t forget to add the reference in the inspector
  • Create a custom Function, SpawnEnemy()
    • Instantiate()
    • after instantiating, set the position of Enemy in a random position by using random range of “x” value
  • To make it spawn in 5 seconds

 

9.2
Enemy Spawning

 

10
Don’t forget to add the reference

 

11.1
“EnemySpawner” Script
  • Create a function, “ScheduleNextEnemySpawn()” to spawn multiple times
    • by using, “Invoke()” and putting “ScheduleNextEnemySpawn()” inside “SpawnEnemy()”
      • without using “loop”, we can make enemy spawned continuously
  • To increase the difficulty of the game, Create a function, “IncreaseSpawnRate()”

 

11.2
Spawning Enemies

UNITY TUTORIAL | PROJECT | Roll a Ball | 1. Setting up the Game

Roll a Ball

Setting up the Game

2
Creating a new project
3
3D Object | Plane

 

4
Resetting Transform of GameObject

 

5
Edit – Frame Selected
6
Seeing GameObject in Scene view with “Frame Selected”
7
Gizmos – Show Grid
8
No Grid Line

 

9
Creating “Sphere” GameObject as Player

 

scale
Changing Values
10
Edit – Frame Selected
11
Sphere | Transform
12
Sphere | Transforma | Position | Y value
13
Directional Light | Material | Background
14
Changing Color of Material
15
Checking Material in GameObject | Default Material

 

16
Applying Material to GameObject

 

18
Wrong Direction of Directional Light
19
Changing Rotation