0

Hey so I'm currently working on a game in unity with a friend mine and we're trying to get the movement of our AI down. Seeing as I'm not currently fluent in C# I was wondering if there was a way to check if a value can be considered as an int (As in, a whole number). The code I want to use this for is here:

while(transform.position != int){
            //Does the actual visual moving
            transform.position = Vector2.MoveTowards (transform.position, monsterPosition, Time.deltaTime * speed);
    }

Thanks for any help you can offer!

  • What type is `position`? A `dynamic`? A floating point that might or might not be whole? – Rogue Jun 27 '15 at 00:11

1 Answers1

2

You can use the % mod operator, to see if there's a remainder:

if(transform.position % 1 == 0)
{
    //It's a whole number
}
Dave Bish
  • 19,263
  • 7
  • 46
  • 63