Unity/게임 엔진 응용 프로그래밍

Vertical 2D Shooting 04 : 레이어된 배경 스크롤링

치명적흑형 2021. 10. 13. 16:21

리소스 배치

 

모든 배경 리소스에 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



참고 코드

https://jsh1.tistory.com/105