So I am making a tank game https://drive.google.com/open?id=1gLhYswcoUNIxp6dFWjuqj3ruqCbGClDZ in which one tank is player controlled and the others are AI that tanks move to a random position. On getting here(when distance between the point is less than 200), I make them change to another random target point to prevent them from shaking uncontrollably. The problem is that part doesn't run and it keeps on shaking.
If you are making a top down tank game then you should really make use of the Pathfinding behaviour. Check it out!
Develop games in your browser. Powerful, performant & highly capable.
it looks like the tanks were getting overwhelmed with commands, and might have been using the wrong tank coordinates in some places...
the left and right directions were getting cancelled by the up/down ones.
I changed it slightly to do all the checking under one "For each tank" event, and made it always choose to go towards the coordinate (X or Y) that it was furthest from the target location. (I also made the target location visible so I could see what it was doing).
EDIT: if your game will have any obstacles on the battle field, then path finding would be a very good idea - like plinkie said...
AllanR I have seen my mistakes. Buh I don't think the occasional diagonal movement was intended though. —I have and will consider using pathfinding. Thank you