I don't know if you've ever played a racing game.
Racing games have signposts on the runway, such as
All of the racing games know that the road signs for most racing games are moving, like, that it moves from right to left
It's not going to make a dynamic map, everybody.
It doesn't matter if you haven't played a racing game, have you ever seen a waterfall or a lake in the game? such as: Mountain stream
Of course, the effect of my map is not very good, but I would like to say here is the principle, do not hinder, we continue to
The waterfall in the picture flows from the top down
We all know that if we use particles, there are hundreds of waterfalls, and it must be very jammed on the phone.
The phone might have just opened and it didn't respond.
Unless the requirements are very realistic, the type of water used in the particle system, can not use as much as possible
The texture animation, although not up to the particle so lifelike, but also a good solution
Does texture animation cost resources or particle animation? Let's explore.
Waiter
Okay, sir, come right now.
This is the material ball of the waterfall, we manually modify the OffsetX
As per +0.1 change: 0.1,0.2,0.3,0.4 ....
We will find that every time the material is modified, the ball will change accordingly.
Now we go to zero, modify the offsety, and still change the same way as X
We will find that the material ball will also change, but the direction is different.
If it is not easy to see the material ball, then hang the material ball on the object so that you can see it clearly
Well, we know that if we let the material ball move and change the offset, then we'll start knocking on the code.
Create a TextureAnimation.cs
Define a variable: public float xspeed = 0.1f;//x Axis Movement speed
And then we have the following code.
1 Public float 0.1f; // x-axis movement speed 2 3 void fixedupdate () 4 {5 new Vector2 (Time.time * xspeed, RENDERER.MATERIAL.MAINTEXTUREOFFSET.Y); 6 }
We hung up on the waterfall, and then we ran, and we found the waterfall moving, but it seemed to move in a wrong direction and speed.
It doesn't matter, we just modified the x-axis, we are adding the Y axis and moving speed is not OK?
Efaro obtains the following complete code:
1 usingUnityengine;2 usingSystem.Collections;3 4 ///Texture Animations<summary>5 ///Texture Animations6 /// </summary>7 Public classTextureanimation:monobehaviour8 {9 Public BOOLMoveX =false;//whether to move xTen Public BOOLToup =false;//Move Upward One Public floatXSpeed =0.1f;//x-axis movement speed A Private floatOffsetX =0; - - Public BOOLMovey =false;//whether to move y the Public BOOLToLeft =false;//Move left - Public floatYspeed =0.1f;//y-axis movement speed - Private floatOffsetY =0; - + - voidfixedupdate () + { A if(MoveX) at { -OffsetX = Time.time *xspeed; - if(toup) OffsetX *=-1; - } - - if(Movey) in { -OffsetY = Time.time *Yspeed; to if(toleft) OffsetY *=-1; + } - theRenderer.material.mainTextureOffset =NewVector2 (OffsetX, OffsetY); * } $}
I don't have much to explain, the landlord came over to collect the rent.
Really annoying, I have rented for half a year, want to renew the lease one months, because there are one months before I go to work
The original rent is 8,501 months, now actually want to charge me 9,001 months
The reason is I only renew for one months
I taught 1000 bucks, and he was afraid I'd run out of water and electricity, and I'd give 1000 bucks.
I asked him to collect the electricity bill and he didn't come, saying it was too cold ....
What kind of man is this?
No, I'm going to flash.
This article link: http://www.cnblogs.com/shenggege/p/4264463.html
Unity3d Texture Animation