Skillfully use textures to make scrolling backgrounds
The main points of knowledge of this study are as follows:
1. How to create a scrolling background.
You can achieve this effect by using the material ball to keep shifting the texture.
2. The difference between time and deltatime "Dog planing Learning Net"
Time.time is the time that represents the game from start to present, and is a growth value.
Time.deltatime is a fixed value that represents the time interval between frames and frames on a machine.
The way to use this is to create a material ball, paste the background we want, have the panel attach the material ball, adjust the camera position, and hang the script on the panel we created earlier.
using Unityengine;
using System.Collections;
Public class Scollerbg:monobehaviour {
Public float xspeed=0.1f;
Public float yspeed=0.1f;
Public float x_scoller=0.1f;
Public float y_scoller=0.1f;
void Update () {
X_scoller = Time.time * xspeed; //From the beginning of the game to the present time
Y_scoller = Time.time * yspeed; //deiltetime is the time between 2 frames
//"_maintex" is the main diffuse texture and can also be accessed through the Maintextureoffset property
Renderer.material.SetTextureOffset ("_maintex", new Vector2 (x_scoller,0));
}
}
Unity mobile development skillfully uses textures to make scrolling backgrounds