EDIT: Even doing (int)2f for me returns 1.
I was getting unexpected answers when a script was run and the x position of the object was at a certain number. So I have this debug here to show you that I made:
Debug.Log ("Before (int): " + Main.worldToGrid (transform.position.x, transform.position.y).x +
" After (int): " + (int)Main.worldToGrid (transform.position.x, transform.position.y).x);
I use the (int) version of that in my code and it turns out wrong sometimes. When Main.worldToGrid (transform.position.x, transform.position.y).x is 0, 1 or 3, the (int) is normal (0, 1, or 3). But when it’s 2, the (int) is 1 for some reason.
Look:
Before (int): 2 After (int): 1
UnityEngine.Debug:Log(Object)
Tile:Start() (at Assets/Scripts/Tile.cs:9)
Does anyone know why? I’m using C#, by the way.
Thanks! It worked. Why does (int) not work though? Any ideas?
– SwissAndOr