OnTriggerEnter adding multiples instead of a single.

When a character enters a safehouse I want the safehouse script var population to increase by one.
What happens now: player enters building and the population increases to 6. It doesn’t simply jump to 6, it rises very quickly. I know this because for a moment it’ll show another number on the way to 6, then do the same upon exit; it’ll count down from 6 very very quickly.

My relevant character code is this

function OnTriggerEnter(other : Collider)
	if(other.tag == "Safehouse")
		safehouseScript = other.GetComponent(Safehouse);
		checkingIn = true;
		inSafehouseVicinity = true;
		safehouseScript.population ++;

and the relevant safehouse script is literally just the variable itself.

it may be worth noting that I have used a ‘human’ update switch (I need the switches to switch between various states such as ‘dead’) BUT I don’t see how this would affect the OnFunctionEnter since that does it’s own thing.

Also why is it stopping at 6?? All I can think of is that the population is being added to/subtracted from every frame as the character is in the process of entering or exiting the collider which could take 6 frames depending on speed?? I doubt it though.

Any suggestions appreciated.

Thanks for the response robertbu, you managed to help me here in a roundabout way, I’ll put the answer up :slight_smile:

Basically the character had 5 objects attached to him (for items etc) and they each had colliders. I disabled them and now it just detects the character.
I had no idea the child object colliders would be detected!

I assume there’s a way to make the trigger only interact with the main script-attached-object’s collider but luckily my objects don’t need colliders anyway so it’s fine for now.
Thanks for the longshot :slight_smile: