0 votes

So i want to make a strategy game like starcraft.
When clicking somewhere on the screen, the player should move to that location.
Because move_to() was removed, i can't imagine how i can create a click-to-move system.
I tried

if Input.is_action_pressed("left_click"): //made an input map for left_click
   move_and_slide(get_global_mouse_position())

but the player can move in just one direction
Help

asked Feb 2, 2018 in Engine by GunPoint (395 points)
edited Feb 2, 2018 by GunPoint

Found the answer myself, i downloaded the pathfinding demo which showed me what i needed

In case it serves to someone, can be subtracted the mouse's position with the character's position, like this:

if Input.is_action_pressed("left_click"): //made an input map for left_click
 move_and_slide(get_global_mouse_position() - position)

1 Answer

+1 vote

You can find this one in official documentation page:
https://docs.godotengine.org/en/3.1/tutorials/2d/2d_movement.html#click-and-move

answered May 19, 2019 by talupoeg (25 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.