0 votes

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?

in Engine by (29 points)

1 Answer

0 votes
Best answer

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.

by (331 points)
selected ago by
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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.