#Parallax Help
1 messages · Page 1 of 1 (latest)
This is what I have now
And this is the code I'm working with to try and achieve it
[SerializeField] bool scrollLeft;
float singleTextureWidth;
void Start()
{
SetupTexture();
}
void SetupTexture()
{
Sprite sprite = GetComponent<SpriteRenderer>().sprite;
singleTextureWidth = sprite.texture.width / sprite.pixelsPerUnit;
}
void Scroll()
{
float delta = moveSpeed * Time.deltaTime;
transform.position += new Vector3(delta, 0f, 0f);
}
void CheckReset()
{
if ((Mathf.Abs(transform.position.x) - singleTextureWidth) > 0)
{
transform.position = new Vector3(0.0f, transform.position.y, transform.position.z);
}
}
void Update()
{
Scroll();
CheckReset();
}
Granted, I still need to figure out how to implement it as a group instead of relying on the size of a singular sprite