![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | GamelandX |
Hi all, I been trying to add an arrow, but no matter what I try Im still unable, at this momnet it is erroring out at line 28, but maybe someone with more experience can tell me where am I really making my mistake, any help is appreciated:
extends RigidBody2D
var dragging
var drag_start = Vector2()
var drag_end = Vector2()
var launched = false
var trys= 3
const Arrow = preload(‘res://scenes/Player/Arrow.tscn’)
var arrow = null
var dir
func _ready():
arrow = Arrow.instance()
add_child(arrow)
arrow.hide()
func _input(event):
if (trys != 0):
if event.is_action_pressed(“click”) and not dragging and not launched:
dragging = true
drag_start = get_global_mouse_position()
if event.is_action_released(“click”) and dragging:
dragging = false
launched = true
trys -= 1
arrow.show()
arrow.get_global_mouse_position()
arrow.get_rotation(dir).angle()
drag_end = get_global_mouse_position()
dir = drag_start - drag_end
apply_impulse(Vector2(), dir * 5)
arrow.hide()
yield(get_tree().create_timer(5.0), “timeout”)
launched = false
It would help your post more if you gave us the error.
Ertain | 2019-02-01 19:25
Also, please format your code to make it readable. Four spaces or press the “Code Sample” button above.
kidscancode | 2019-02-02 02:04