Hi all,
what I am trying to achieve is make an arbitrary mesh object gradually appear burned. Imagine a tree or furniture catching fire at the bottom and burning upwards getting gradually darker as the fire moves along (only for areas that the fire has touched of course).
Any suggestions on how this would be done efficiently? The mesh models are created externally to Unity.
Thank you for any tips,
Kostas
set color something near to black for models material
OR change texture of models material
OR use specific shader.
I would prefer first one
Something like this will work for you:
using UnityEngine;
using System.Collections;
public class BlackBurn : MonoBehaviour {
public float burntime = 10.0f;
public GameObject go;
public Color endcolor = Color.black;
private Color startColor;
private Color delta;
// Use this for initialization
void Start () {
startColor = go.renderer.material.color;
delta = startColor/burntime;
Debug.Log(delta.ToString());
}
// Update is called once per frame
void Update () {
if( burntime > 0.0f)
{
burntime -= Time.deltaTime;
go.renderer.material.color -= delta;
Debug.Log(go.renderer.material.color.ToString());
}
}
}
Though you may want to expose more options for it.