Page 1 of 1

character_running_speed inaccuracy

Posted: Mon Aug 01, 2022 8:48 am
by proicop
Hi!

I am trying to precisely predict how long it will take for a character to walk from a point a to a point b on a straight/diagonal line. I found the `character_running_speed` property of the character which is equal to `0.15`. This leads me to believe that the character will move exactly `0.15` tiles per tick.

I am setting the character's moving state every tick and printing its position and from my testing it seems like the character is actually moving exactly `0.1484375` tiles per tick instead when moving along a straight line. Are there any other modifiers that I should account for?

Re: character_running_speed inaccuracy

Posted: Mon Aug 01, 2022 12:19 pm
by PFQNiet
Many positions are in multiples of 1/256, and the closest multiple of that to 0.15 is the number you have found, which is 38/256.

I'm not sure how this will affect diagonal speed, but if it's preserving speed then you would travel 27/256 of a tile in each axis.

Re: character_running_speed inaccuracy

Posted: Mon Aug 01, 2022 12:21 pm
by Klonan
The game only stores positions as 1/256 of a tile,
So then it moves the 0.15, it rounds to the nearest valid position

0.15 = 38.4 / 256
0.1484375 = 38 / 256

Re: character_running_speed inaccuracy

Posted: Tue Aug 02, 2022 11:52 am
by proicop
Ok that makes sense. Thanks!

Re: character_running_speed inaccuracy

Posted: Thu Aug 04, 2022 10:29 am
by darkfrei
What if the speed is less than 1/256 tiles per tick? No movement at all or the movement will be accordingly accumulated?

Re: character_running_speed inaccuracy

Posted: Thu Aug 04, 2022 3:28 pm
by DaveMcW
There is no accumulation, all rounding errors are discarded.