Godot Version
4.2.2
Question
Hi, I’m working on a mechanic where you can draw with a mouse a trajectory for a projectile to bypass obstacles created by enemies.
extends Line2D
var projectile = preload(“res://projectile.tscn”)
var array_pos: Array =
var count = 1
func _input(event):
if Input.is_action_pressed("path"):
var mouse_pos = get_global_mouse_position()
var instance = projectile.instantiate()
add_child(instance)
add_point(mouse_pos)
array_pos.append(event.position)
instance.position = array_pos[0]
if Input.is_action_just_pressed("launch"):
for i in array_pos:
pass
So basically I draw a line with Line2D and then store a set of coordinates in the array, but I don’t know how to make the sprite follow them.