I was creating this function when the player hits an object (eg. butterfly) it will destroy and I have an OnGui function that will count how many butterfly he gets.
My problem is when I enter my Object (which is water created using Cube) that has a trigger too…
private var defaultFog = RenderSettings.fog;
private var defaultFogColor = RenderSettings.fogColor;
private var defaultFogDensity = RenderSettings.fogDensity;
private var defaultSkybox = RenderSettings.skybox;
var noSkybox : Material;
function OnTriggerEnter()
{
RenderSettings.fog = true;
RenderSettings.fogColor = Color (0, 0.4, 0.7, 0.6);
RenderSettings.fogDensity = 0.04;
RenderSettings.skybox = noSkybox;
Time.timeScale = 0.75;
}
function OnTriggerExit()
{
RenderSettings.fog = defaultFog;
RenderSettings.fogColor = defaultFogColor;
RenderSettings.fogDensity = defaultFogDensity;
RenderSettings.skybox = defaultSkybox;
Time.timeScale = 1.0;
}
My counter automatically adds 1 whenever I get to the water. How can I restrict my counter that it will only count when I trigger the butterfly and not the water? Thanks!
PS: the butterfly obj have this scripts.
var bCatch = 0.0;
function OnTriggerEnter()
{
//this method get executed when something collides against
//the butterfly which has the current script attached.
Destroy(gameObject);
bCatch += 1;
}
//this method is always executed (at least twice per frame render)
function OnGUI () {
//Rect = x, y, width and height... + text
GUI.Label(new Rect(10, 10, 100, 100), "Garbage: " + bCatch);
}