My screen isn't scrolling

I just finish lesson 125 and this is happen. My screen are shivering insted of scrolling.

Shivering Screen (2)

Anyone knows what could be the problem? I made every step has Gary does in the video.

I Have A few checks with in the engine itself, Since there is no code posted.

Is your wrap mode set to repeat?
Is your SpriteScroller.cs script attached to both stars_0 and Stars_1 with different values on the Y Axis(since you are moving in that direction)

If these are the case, and have not fixed your issue please post the .cs script so we can take a look

Sorry for didn’t post the code before, but here is:

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

Vector2 offset;
Material material;
void Awake()
{
    material = GetComponent<SpriteRenderer>().material;
}


void Update()
{
    offset = moveSpeed * Time.deltaTime;
    material.mainTextureOffset = offset;
}

}

And yes, both stars_0 and stars_1 are with the wrap mode set to repeat, and yes, both are with different values on the Y axis

Ah your missing += the offset!

= Operator sets the value on the right to the variable on the left, Whilst
+= Operator Updates a variable by incrimenting its value and reasigning it.

void Update()
{
        offset = moveSpeed * Time.deltaTime;
        material.mainTextureOffset += offset;

}

Hope this helps!

1 Like

Good catch, @LaniganDev! :slight_smile:

@Terezu, in many cases, things don’t work because of little typos like this. For this reason, Gary shared his code online, so it is easier for his students to compare their code with his. The link to his code can be found in the lecture code changes, which you can access via the link in the Resources of each lecture.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms