Using Time.deltaTime when incrementing a value

I’m incrementing an int variable (kind of a heat system) each time player jumps, keeps holding the jump key and when he moves around. I use addForce method to move the character. All this is happening inside a FixedUpdate function. Do I need to use Time.deltaTime when I’m incrementing or reducing the int value? How do I generally know when to use time.deltaTime?

Below there is a code example of the jump block I have in my character controller script.

if(Input.GetButton("Jump")) {
  GetComponent<HeatController>().GainHeat(50);    // Is time.deltaTime needed here?
  rigidbody2D.AddForce(new Vector2(0f, jumpForce));

Values that change over time should generally be expressed in units-per-second. If they aren’t, they will implicitly depend on your frame rate, which can vary wildly.

Time.deltaTime tends to be very small. For example, let’s pretend that your game runs at exactly 50 FPS (it won’t, but it makes the math easy). That gives you about 0.02 seconds per frame. Let’s say you want to gain 100 heat per second, while whatever thing is running. Multiplying that 100 by 0.02 gives 2 heat per frame, running that for 50 frames gives 100 heat total.

This stuff gets more intuitive if you learn calculus. :slight_smile:

This does bring us to one other problem, ints versus floats:

int x = 1f * 0.5f; //result is "truncated", x is now zero
float y = 1f * 0.5f; //result is correctly 0.5f

Integers don’t ever store a fractional part of your numbers; they “truncate” or discard it completely. Values which need to store fractional parts should usually be floats. If you need to know more about this, most people first run into it with a concept called “integer division”, which you can read up on.