animating terrain texture question

When I was playing around in the terrain editor and accessing the edit terrain texture function, one of the things I did was scroll the texture’s tile offset which created a nice effect of the ground texture moving in one direction.

I’m trying to figure out how to do this in code so it will animate like that in runtime. I’ve done some research on the terrain and the closest thing I’ve found was this:

which basically tells me that I need to access each individual alphamap by iterating through a copy of the terrainData’s alphaMaps and then setting the alphaMaps on the terrainData to the copy after modifying it.

It’s also clear that you can change between two textures, but I was wondering if it would be possible to constantly change (every frame) to a new texture, with 60 textures total (each one with a tile offset of an additional 0.0167 (1/60th))

I was thinking of extending the method listed above but I can’t find out how to add textures to the splats array of the terrain without painting them all on one by one.

Any suggestions?

I made some research on this too, wanted to make some kind of water refractions, but my framerate went pretty low with what I found

var terrain:Terrain;
var splatPrototypes : SplatPrototype[];
function Start () {
	splatPrototypes = terrain.terrainData.splatPrototypes;

function Update () {


In my case splatPrototypes[2] is the texture i want to offset, (Which is the third texture on my Terrain paint textures)

I tried accessing the tile offset directly (terrain.terrainData.splatPrototypes[2].tileOffset.x+=0.1;) but for some reason I can only affect it by changing the whole array, which is in fact, a framerate killer, but for now this works to offset the texture, hope someone finds a better solution :slight_smile: