![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | johnguild26 |
My current script works using for loop of instances, but is there any easier or lighter approach like get_node_by_instance_id(id) ?
Ived checked the documentation Node Section but did not find any.
Anyway here’s my current script:
extends Node2D
var selected = null
var entity_nodes = []
func _ready():
entity_nodes = get_tree().get_nodes_in_group("entities")
func pick(instanceId):
selected = instanceId
print_debug(instanceId)
func drop():
for entity in entity_nodes:
if entity.get_instance_id() == selected:
entity.set_target_position(get_global_mouse_position())
selected = null