Sure. What I did was animate a texture. (This works for any type of texture.)
This is not a very good idea if you do not want many MATERIALS (Let alone many textures for each material) but if you do not care for whichever reasons then this is how it was done.
(Please note none of this explains how to animate. We assume you already have your animation prepared)
Method 1:
Material changing
-Requires knowledge of the Animation window and how to use animation in Unity. (Animator window)
This example we will make rain falling on the ground.
1: Add a material for every texture.
- This example we will use 30 frames of animation, so 30 materials in some folder named the name of your choice. (Preferably the name of the animation, in this case… Let’s say Rocky Terrain Rain Animation)
2: Make an animation for the game object that will house the rocky terrain texture. Perhaps call this animation “Rainy”.
- You can feel free to put your rocky texture (Non animated) on the terrain for when it’s not raining perhaps.
3: Open the Animation window and IN ORDER put all 30 materials that have the 30 different frames of animation in the animation window timeline.
If you press play on the animation, it will go through every frame of animation. In this case, all it’s doing is change one MATERIAL to the next.
This is if you wish to use the Animation window to animate your texture. I do not believe this works properly with Terrain. Did not mess around much with that.
TERRAIN TIP
You can convert the mesh of your terrain into a game object and animate it that way. I am pretty sure it is also possible to keep the textures on there but that might require plugins. IF for whatever reason you cannot do that, a quick and nasty way to get that texture of the terrain is going into orthographic view (Top down) and the terrain will now be flat. Simply screenshot the terrain, crop the image to ONLY the terrain and apply that to your game objected-converted terrain. Even more, you can also re-UV the terrain if you wish if the texture not properly placed on the terrain. This method on terrains, though, breaks the functionality of terrains since you are converting but in the end you can then animate the terrain’s texture(Material, really) this way.
Method 2:
Texture changing
- Requires programming of: Time-based events and material programming.
This example is the same as Method 1 but without the use of the Animation Window OR 30 different Materials.
1: Create ONE material and have all of the animation frames simply as unassigned textures.
- You can, again, have the NON rain material as the material’s texture.
2: Apply the material to the ground.
3: Create a script called whatever you wish. I will not use actual scripts, assuming you know basic scripting.
4: Have slots for all 30 textures.
- You can do this however you wish but If you are using MonoBehaviour then I’d just label it 1-30. (Or 0-29?)
5: If you are using the MonoBehaviour method, what I’d use, each slot should MATCH the frame of the animation. We are sort of making out own animator. Slot 1 should be on Frame 1 of the animation. Assign them.
6: Create the simple algorithm that allows the script of the game object the script is attached to (Or whichever game object you wish. But in this case the animated texture would be the one on the ground. So the ground would be what the script is attached to or simply affecting.) change the texture of the material whenever you wish.
- In this case, maybe, depending on your animation, 20 framed per second. Using your own methods program every, say, 0.05 seconds to cause the material’s texture to change to the next texture which would be the name in the list of slots. Since this is not an actual animation, you’d need a way for it to start and continue the process in the script.
Method Conclusion:
Both methods take different approaches and have their pros and cons. One may require programming and skilled programming to avoid processing issues. The other requires small animations file(s) and/or many material files.
Please note, the TERRAIN TIP works for BOTH methods. There is also another tip with applying the animated texture rain texture.
Layer Tip:
One possible way is by choosing one method and going through with it HOWEVER. putting it on a LAYER object. This also allows you to “Animate” the texture of a terrain and keeping the object a terrain.
To do this: apply the method to a game object you wish to animate HOWEVER. ensure the animation is hollow. Example: If you want a “Wet moving watery look” to the ground, create a transparent alpha texture that would blur the texture under it and have it animated. Apply this transparent alpha animation as the animation to an object that is the same shape as the ground (Or close to it) and apply it directly above/around the ground. So the ground keeps its static Rocky Terrain texture but transparent alpha animation on top of it makes it look as if it is animated but is actually an animated layer. You can do this with many layers that serve many purposes. Such as a reflection layer above the texture, etc. But as long as it has alpha, you will see the texture under it which is the rock.
I would like more efficient ways of doing this since none of these seem very appropriate but this is how I did it.