- Home /
Best way of scrolling a texture without lagging?
Hi,
I have a panel representing the 2D background of my game. It is constantly scrolling/offsetting it's texture with the following code:
var scrollSpeed : float = 0.5;
function Update ()
{
var offset : float = Time.time * scrollSpeed;
renderer.material.SetTextureOffset ("_MainTex", Vector2(0,offset));
}
This works fine when playing in the Unity player, iOS and Android. However, in the webplayer it kinda lags. Every so often it stops for a fraction of a second. Is there a better way of scrolling the texture or are there settings that create this behavior in the webplayer?
Thanks.
Is it only the scrolling texture that lags? Perhaps the whole game is lagging but the texture is the most obvious sign.
Take a look and tell me what you think. The truck seems to move fine. If it's the game, how can I optimize it for web?
i think that game is GREAT ! one suggestion, when "game over" yellow sign appears. just make it delay for 1 second before it appears. ie, you crash. maybe the thing you crashed into flashes fast for 1 second. THEN the sign appears. that will really help !!
I see NO LAG, WHATSOEVER. and I bothered to test it on a 5 yr old mac we have for Old Testing. no problem.
It is hard to tell. On my hardware I see a bit of a stutter just before the truck is parked, but the rest of the game ran fine. And it was hard to see if the stutter was overall or just the background. Put a FPS display on the game to see if the issue is an overall drop in frame rate or something to do with the scrolling texture.
Your answer
![](https://koobas.hobune.stream/wayback/20220613100210im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Texture offset causes stretching 1 Answer
Simple modding via importation of text files and jpgs 2 Answers
How to start Unity app from web page in iOS or Android 1 Answer
Offset texture on an object 1 Answer
can't offset normal map 1 Answer