A little flair to the scrolling background

I added a bit more scrolling to the background so it moves a little with you when you move around.

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

public class SpriteScroller : MonoBehaviour
{
    [SerializeField] Vector2 moveSpeed;

    Vector2 offset;
    Material material;

    Player player;

    Vector2 playerVector;
    void Awake()
    {
        player = GameObject.Find("Player").GetComponent<Player>();
        material = GetComponent<SpriteRenderer>().material;
        
    }


    void Update()
    {
        Vector2 playerVector = new Vector2(player.rawInput.x * 0.3f + moveSpeed.x, 
        player.rawInput.y * 0.3f + moveSpeed.y);

        offset = playerVector * Time.deltaTime;
        material.mainTextureOffset += offset;
        //Debug.Log("test" + player.rawInput[0]);
    }
}

Privacy & Terms