리소스 배치

모든 배경 리소스에 BackgroundController스크립트 부착

스크립트 수정
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BackgroundController : MonoBehaviour
{
public float speed;
void Update()
{
transform.Translate(Vector2.down * this.speed * Time.deltaTime);
if (this.transform.position.y < -11)
{
this.transform.Translate(new Vector2(0, 24));
}
}
}
Top 오브젝트 speed : 6
Middle 오브젝트 speed : 4
Bottom 오브젝트 speed : 2
참고 코드
'Unity > 게임 엔진 응용 프로그래밍' 카테고리의 다른 글
| Vertical 2D Shooting 06 : 적기 자동생성, 피격 애니메이션 (0) | 2021.10.14 |
|---|---|
| Vertical 2D Shooting 05 : 적기 파괴 (0) | 2021.10.13 |
| Vertical 2D Shooting 03 : 플레이어 공격 (0) | 2021.10.13 |
| Vertical 2D Shooting 02 : 플레이어 이동 (0) | 2021.10.13 |
| Vertical 2D Shooting 01 : 게임기획 (0) | 2021.10.13 |