How i do detect mouseclick without buttons

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CrazyMind

I don’t know to detect mouseclicks and the position of it . I need it to make the player throw a fireball toward the mouse. Can someone show me a script for it?

:bust_in_silhouette: Reply From: RoniPerson

In this case you would first detect a mouse click in your player script.
For this you would use if Input.is_action_just_pressed("mouse_click").
Then you can use Node2D.get_global_mouse_position() to get the position where the cursor is in world space. With that you can calculate your aiming.