Question for newest godot it is an old question but it is not working for me.

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

https://forum.godotengine.org/17655/arrow-point-direction-circling-around-circle-based-vectors

Basically this would work for me perfectly but this line I cant figure it out, using a mouse

arrow.set_rot((finger_pos - finger_down).angle())

Im out of ideas Im not sure how to handle this line on current godot.

This is my full code:

extends RigidBody2D

var dragging
var drag_start = Vector2()
var launched = false
var tries= 3
const Arrow = preload('res://scenes/Player/Arrow.tscn')
var arrow = null

func _ready():
	arrow = Arrow.instance()
	add_child(arrow)
	arrow.hide()

func _input(event):
	if (intentos != 0):
		if event.is_action_pressed("click") and not dragging and not launched:
			dragging = true
			drag_start = get_global_mouse_position()
			arrow.show()
			arrow.get_global_mouse_position()
			arrow.rotation(finger_pos - finger_down).angle()
		if event.is_action_released("click") and dragging:
			dragging = false
			launched = true
			tries-= 1
			arrow.hide()
			var drag_end = get_global_mouse_position()
			var dir = drag_start - drag_end
			apply_impulse(Vector2(), dir * 5)
			yield(get_tree().create_timer(5.0), "timeout")
launched = false

rafah | 2019-01-24 13:31

:bust_in_silhouette: Reply From: kidscancode

set_rot() has not been valid since Godot 3.0 released. Abbreviations were phased out in Godot 3, so the function was named set_rotation. In addition, rather than using set/get functions, you can access the named property directly, like so:

arrow.rotation = (finger_pos - finger_down).angle()

Ah cool thanks, may I ask where finger_pos - finger_down come from? on my Original code I use event.is_action_pressed(“click”) does it means that I need to rewrite my code to have the named properties?

rafah | 2019-01-24 13:19

I have no idea where those variables come from. I just used them because you had them in your original question. I suppose they could be talking about the properties of InputEventScreenDrag.

kidscancode | 2019-01-24 15:18