Scripting problem (OnTriggerEnter)

First, I have 2 trigger objects.

1. Water
2. Butterfly

I have a code that when I enter trigger on Butterfly. The object(Butterfly) will destroy and add 1 to my GUI which has label (Butterfly: “number of triggered butterfly”)

My problem is when I triggered the water which has these scripts:

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 GUI will add one again which is not appropriate because it is use to count butterfly.

My code in the butterfly is:

	function OnTriggerEnter()
	{
		//this method get executed when something collides against
		//the butterfly which has the current script attached.
		Destroy(gameObject);
		
		
	}

and in my Controller:

function OnTriggerEnter()
	{
	butterCatch += 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: " + butterCatch);
	}

How can I code that it will count only when I triggered the butterfly? Thanks!

Use Tag inside your triggers fct to detect the object you collide with and that you should fix your problem

http://forum.unity3d.com/viewtopic.php?t=62234

What is the advantage in posting twice your problem ? -_o

Sorry sir AkilaeTribe!
Im still noob here in Unity Forums and in Unity Game Dev. I accidentally post knowing my first post is wrong. BTW, Your so good at both Unity game dev and forums that makes you look like Bill gates’… ass! and Im not taking advantage of it.

The fact that you post twice is not especially bothering, but I feel a good amount of sarcasm behind your last answer. I highly doubt this is the best attitude to have when asking help from others…

I am asking for a good reply like codes or ideas not your criticism. I started Unity merely 24 hours and damn I think your good at this for making me look like stupid. Please if you raising your Posts don’t do shit on me.

I am not forcing you to help me or others like me. So please if it’s not helpful don’t click post reply

Thanks @ giyomu that idea help! Thats what I’m asking for. I hope that this COCK-lover-avatar learns from you and by the way AkilaeTribe nice avatar! fits on you.

I think I helped you enough by showing you a bit of code available that show you how to link the function OnTriggerEnter and the related object that triggered it.

If you didn’t understand, you could have told it, I would have explained more, but instead, you created another topic. I asked you why you would do that, and you started saying nonsense.

You don’t need me to do that.

I wanted to be helpful but I won’t do that mistake again…with you.

Alright! Since you got many post count I am wrong here.

PS: Please change your avatar. It reminds me of justin bieber.

No one wants the chicken : he is too fat.

Regarding of the post count, I don’t see how it is relevant.