Hello fellow game devs.
Im struggling to make an opening/intro scene from my very first game.
My idea is that a catastrophic event ocurred and turned my beautifull grassy land into a frost place. So my animation need is to change that “grassy” terrain texture layers into “snowy” terrain texture layers.
Based on this i’ve created a simple script to make a public method to do the layer change.
this script is a component for the Terrain Object:
private Terrain terrain;
public TerrainLayer[] grass;
public TerrainLayer[] snow;
void Start()
{
terrain = GetComponent<Terrain>();
}
public void GrassChange()
{
ChangeLayers(grass);
}
public void SnowChange()
{
ChangeLayers(snow);
}
void ChangeLayers(TerrainLayer[] newLayers)
{
TerrainLayer[] layersAtual = terrain.terrainData.terrainLayers;
if (newLayers.Length != layersAtual.Length)
{
Debug.LogError("Layer quantity incorrect");
return;
}
for (int i = 0; i < layersAtual.Length; i++)
{
layersAtual[i] = newLayers[i];
}
terrain.terrainData.terrainLayers = layersAtual;
}
Both methods SnowChange() and GrassChange() where tested with sucess through UI Buttom call (wich is runtime).
Altough when i call the method using Animation Event nothing happens
Any toughts over that problem im facing? Maybe some other ideias on workarounds or other ideas on how achieve the expected animation.
Thanks and kind regards
JRBorba