Code: [Select]
toPlayerX = playerx - x;
toPlayerY = playery - y;
toPlayerLength = (toPlayerX * toPlayerX + toPlayerY * toPlayerY) ^ 0.5;
toPlayerX = toPlayerX / toPlayerLength;
toPlayerY = toPlayerY / toPlayerLength;
x = x + toPlayerX * this.speed;
y = y + toPlayerY * this.speed;
This has the showpoly moving in a very fluid manner. The problem is it never reaches the exact target coordinates (always off by a few hundredths of a decimal point). This causes some very weird visual glitches where the showpoly will 'bounce' between two coordinates. If I could control the increments (to 0.05 for example) that it moved that would solve my problem, but I don't really understand the math enough to do this. Can you help me out?