I am trying to get one off my int
statements to take a float
statement because in my game, the sprite uses a float
to get the coords of where it is at. However the tilemap uses int
to get the location of the tile. Why cant you use an int
and float
in the same statement and if its an obvious answer how do you go about changing it without having to use casts in other methods?
You can't assign a float
value to an int
variable because some of the information will be lost. For the same reason, you can't pass a float
value to a method whose argument is declared as an int
. (your question is rather unclear due to the incorrect use of terminology, but I think you are trying to do the latter)
You can tell the compiler that you really do want to lose the information (the fractional part of the float) by using a cast operation. That is the how, and the why.