Weird visual glitch in game viewer

While working on the delivery driver portion of the unity 2d course I found that I’m experiencing a weird visual glitch. Changing the steerSpeed/moveSpeed in the sterilized field makes the sprite disappear from the game view. It does not go off the screen it simply just disappears.

you can see I only added 0.05 to the speed so only slightly faster and it works for a second then the sprite disappears.

Is this something I’m messing up? Tank you!

1 Like

Hello! Welcome to the community!

Here’s the reason why your sprite disappears. See the Transform’s position in the first screenshot you posted, now watch the second one, as you can see, the Z position was 0, then it went to 1612, your sprite is there, but is way off the camera’s range, that happens because in your script you are incrementing the Z position of your sprite.

To avoid that, in your Update method, remove the 1 from the Translate line, it should look like this instead:

transform.Translate(0, moveSpeed, 0);

Hope this helps!

1 Like

Thank you so much! That fixed the issue. I’m new to coding and overlooked this.

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

Privacy & Terms