Page 1 of 1

Strange % issue in GE

PostPosted: Tue Mar 26, 2013 2:06 am
by bamby1983
This works:
Code: Select all
if (frame%2==0)
    x+=1;



But GE does not allow this to execute and says it's an error:
Code: Select all
if (animpos%2==0)
    animpos+=1;


Would anyone know why?

Re: Strange % issue in GE

PostPosted: Tue Mar 26, 2013 2:40 am
by skydereign
That's because % can only be used with integers, and oddly enough, animpos is not an integer. You can cast it to be one though, so putting (int) before it will make that line work.

Re: Strange % issue in GE

PostPosted: Tue Mar 26, 2013 3:14 am
by bamby1983
skydereign wrote:That's because % can only be used with integers, and oddly enough, animpos is not an integer. You can cast it to be one though, so putting (int) before it will make that line work.

Thanks Sky! You know everything about GE, don't you! :)

I thought animpos would have been an integer coz you can't have a fractional value of the animation position.

Re: Strange % issue in GE

PostPosted: Wed Mar 27, 2013 10:52 pm
by Hblade
Try adding an (int) just before anipmos (With the ( and ) )

Re: Strange % issue in GE

PostPosted: Thu Mar 28, 2013 4:23 am
by bamby1983
Thanks hblade. +1 for you although sky answered this.