- Home /
Burning object, making it appear gradually black
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
Answer by G_Sacristan · Jun 07, 2011 at 03:19 PM
set color something near to black for models material OR change texture of models material OR use specific shader.
I would prefer first one
Answer by tnetennba · Jun 08, 2011 at 10:31 AM
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220612100721im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
how to make walls(surfaces) black(after fire effect) when fire is passed through 0 Answers
Texture color is not right after import 0 Answers
texture import gamma settings 0 Answers
How to make a part of a texture on an object seamlessly change to another texture? 0 Answers
programmatically create a texture or change a texture's color? 3 Answers