Objects that are triggers don't have collison?

[Using FPS Controller and C#]
So I was trying to make it so that there is a heating mechanic, and you get hotter as you touch it, so my code is

int Heat = 0;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag(“Hot”))
{
Heat += 1;
Debug.Log(Heat);
}
if (other.gameObject.CompareTag(“Cold”))
{
Heat -= 1;
Debug.Log(Heat);
}
}

But when I touch the object, it increases by only one and it has no collision?
The script is on the fps controller.
It’s checked as a trigger, otherwise heat doesn’t change and it does have collision. How can I make it so heat is changed overtime, as if it was real?

OnTriggerEnter works by taking the first frame that the Collision has been entered in.
So you’d want to use OnTriggerStay, which means that while the object is in the trigger, the code will execute. However this will now execute every frame the Object is in the trigger.

To combat this, will need to use TIme.deltaTime, which wont allow us to use an integer, so we’ll need to use a float value instead of an integer.

This code should get you along your way, I tested it and it works, just make the appropriate conversions.
Also if you want to have it still have a collider? Just add in a second collider and set that one to not be a trigger.

float Hot; //The value that stores Hot

void OnTriggerStay(Collider Other) //Executes the code once every frame while true
{
    if(Other.tag == "Player") //Checks for what we want to interact with this
    {
        Hot += 1 * Time.deltaTime; //Increases the value of Hot by 1 every second.
        Debug.Log(Hot); //Tells us what the value of hot is
    }
}

Maybe you can convert the value to be an integer later on, but you can still make checks that will treat your Hot and Cold values as an integer, so just work around it if you can.

The function OnTriggerEnter only fires once, on entering. Same thing for OnTriggerExit. I believe what you want is OnTriggerStay. Same basic functionality but fires every frame. Good luck :slight_smile: