... | ... | @@ -2,3 +2,46 @@ |
|
|
Defense_Game 만들기
|
|
|
==================
|
|
|
> ## Enemy object만들기
|
|
|
### 1.Enemy object를 prefab으로 저장 하기
|
|
|
* prefab : Asset에 존재하며 prefab instance들을 형성해 게임 안에서 사용 하게 된다.
|
|
|
* prefab을 사용 하는 이유는 Hierarchy의 object들은 복사했을때 원본인 object가 삭제 되면 모두 사라 지지만 prefab을 이용한 복제는 다른 Enemy Object가 삭제 되도 영향을 받지 않기 때문에 사용 한다.
|
|
|
* prefab 형성 방법은 Hierarchy창의 Object를 Inspector창으로 드래그 해서 만들 수 있다.
|
|
|

|
|
|
|
|
|
> ### 2.`Movement2D.cs` : Enemy Object의 새로운 위치
|
|
|
* Moveto 함수로 direction을 받아서 새로운 위치를 계속 UPdate해준다.
|
|
|

|
|
|
|
|
|
> ### 3.`Enemy.cs` : Enemy가 waypoint대로 움직이도록
|
|
|
* Setup 함수 : waypoint들의 좌표 대로 Enemy가 가야 할 경로 설정
|
|
|

|
|
|
|
|
|
* `Onmove 함수` : 목표지점을 잡을 수 있도록
|
|
|

|
|
|
|
|
|
* `NextMoveTo 함수` : 다음 waypoint를 생각
|
|
|

|
|
|
|
|
|
* `OnDie 함수` : 마지막 wayPoint에서 Enemy Object 삭제
|
|
|

|
|
|
|
|
|
> ### 4. Enemy Prefab에 `Movement2D.cs` 와 `Enemy.cs`을 적용
|
|
|

|
|
|
|
|
|
> ### 5. `EnemySpawner.cs` : Enemy Object 생성
|
|
|
* `Awake 함수`: SpawnEnemy 함수를 실행 시킨다
|
|
|

|
|
|
|
|
|
* `SpawnEnemy 함수`: prefab복제해서 waypoint대로 가도록 함
|
|
|

|
|
|
|
|
|
* `DestroyEnemy 함수`: Enemy 삭제
|
|
|

|
|
|
|
|
|
> ### 6.EnemySpawner Object에 EnemySpanwer.cs 넣은후에 EnemyPrefab,Spawn Time, waypoint 지정
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|