Rotating the arrow on my project

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

Hi all, I’m having issued making the arrow on this project follow the mouse to show the direction where the ball will be launched, can some one help me please?

Hi rafah, perhaps you should put more effort in writing your question. Not everyone may want to download, unzip and run your demo project (while offering this additionally isn’t wrong anyway). So people might want to know if you asking for 2D or 3D or godot 2.x, 3.x at least.

My guess is that you do a 2D project.
Then you could put up a control on the viewport and get mouse movement events via func _input(event) : this will give you global mouse coords in event.position (just check via event is InputEventMouseMotion that you got the correct event).

Then you set up some control or sprite for the arrow (Might want to set the pivot offset to the center if you use a control). You should get the rotation value for the arrow by calling .angle_to(event.position) using the arrows center position vector2.

wombatstampede | 2019-02-12 08:56

Thanks my friend, this is my Original question, :slight_smile:

Want to rotate the arrow with input - Archive - Godot Forum

rafah | 2019-02-12 15:05