I always use public float when I want to add a number to a gameobject but I just saw a unity tutorial that used integer, and I was kind of confused about what should I use in scripts.
Can anyone explain to me what’s the difference between them?
I always use public float when I want to add a number to a gameobject but I just saw a unity tutorial that used integer, and I was kind of confused about what should I use in scripts.
Can anyone explain to me what’s the difference between them?
a float is a number that can have any number of decimals and an integer is a whole number it can be positive or negative
Integers are number which don’t support a fractional component. On the other hand, floats are like integers, but they do support fractions too. So in your case, you may like to use int instead of floats, as you won’t need to use a fractional number - you would call GameObjects 0, 1, 2… and not 0, 0.1f, 0.2f…
Thanks for helping.