Custom Background Movement

Since I’ve made little animated stars in the background, had to use a different approach to get a similiar result.

Laser_Defender_Custom_Background_Trimmed

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class StarScroller : MonoBehaviour
{
    [SerializeField] private Vector2 moveSpeed;
    [SerializeField] private float upperBound;
    [SerializeField] private float lowerBound;

    private void Update() {
        Move();
        CheckPosition();
    }

    private void Move() {
        transform.position += (Vector3) moveSpeed * Time.deltaTime;
    }

    private void CheckPosition() {
        if (transform.position.y <= lowerBound) {
            Debug.Log(gameObject.name);
            transform.position = new Vector3 (transform.position.x, upperBound, transform.position.z);
        }
    }
}
1 Like

The stars look amazing! Wonderful job!

Privacy & Terms