I’m currently using a sprite with an unlit/transparent material attached in order to implement some parallax background scrolling. However, as the sprite is scrolled, part of the sprite is getting clipped on the right-hand edge.
The video to show the effect in action is here:
Finally, the code to do the scrolling is here:
public class ParallaxBackground : MonoBehaviour
{
[SerializeField] private float scrollSpeedRatio = 1.0f;
private Material material;
private void Awake()
{
material = GetComponent<SpriteRenderer>().material;
}
//This method should be called repeatedly in an Update method (see the ParallaxScroller class).
public void StepScroll(float speed)
{
float offset = Mathf.Repeat(material.mainTextureOffset.x + speed * scrollSpeedRatio * Time.deltaTime, 1.0f);
material.mainTextureOffset = new Vector2(offset, 0.0f);
}
}
I’ve also added some images in case they would be of any assistance:
Clipped:
Normal:
Any insights as to why this effect is occurring is greatly appreciated. Thanks!