VeryI am very new to programming. Trying, and trying to get my player to walk to the mouse click position. I currently have this script, which "teleports" my character to the clicked position:
private void getInput() {
xMove = 0;
yMove = 0;
float tempX = handler.getMouseManager().getMouseX();
float tempY = handler.getMouseManager().getMouseY();
float diffX = tempX - x;
float diffY = tempY - y;
if (handler.getMouseManager().leftPressed) {
x = tempX;
y = tempY;
}
}
currently have this which "teleports" my character to the clicked position.
The first thing that came to my mind was to use (forthe following script, for moving to a click which is to the right):
if (handler.getMouseManager().leftPressed) {
if(diffX>0) {
for(float counter = 0; counter = diffX; counter++)
xMove = speed;
}
}
However, this doesntdoesn't work. Any pointersHow would I go about making my player walk to the mouse click position?