Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | BennieBe |
Hi!
I have a question about using a direction vector and ensuring that a player reaches a specific target position using the mouse. I know that I can calculate the direction vector by subtracting the source from the destination position and then use this Vector in my move_and_slide function to reach a specific point based on mouse position, similar as depicted here:
https://www.davidepesce.com/2019/10/14/godot-tutorial-5-1-dragging-player-with-mouse/
Now, what I try to do is let the player move to the mouse position based on a mouse click. I am able to get to the point of the mouse position but unlike the example of above link, the player does not stop and just walks over that position. I know that I can simply use an if condition to check whether the character has reached his position, but I was wondering if there is a more elegant solution to this? I thought that the move_and_slide function would cater for only moving to that specific position if I pass in the respective Vector position. What other options would there be to ensure that the character stops at exactly the point where the mouse has clicked?