Godot Version
Godot Engine v4.5.stable.official.876b29033
Question
I currently have a dragbox that is abel to “select” single or multiple entities and deselect them.
I’m currently trying to make use of the “Empty Array” to do something. In my case, “Auto Select” another entity.
The “Selection” is basically a Sprite3D named “Selected_Indicator” that shows when the array is populated and empty that same array when the user clicks elsewhere
func get_dragbox_selected_objects(selectable_list:Array,dragbox_rect:Rect2) -> Array[Node3D]:
var selected_array:Array[Node3D] = []
##Current problem to solve
while selected_array == []:
obj_default_selection.obj_selected_indicator.show()
## ^To solve
for object:Node3D in (selectable_list as Array[Node3D]):
var position_in_2d:Vector2 = get_viewport().get_camera_3d().unproject_position(object.global_position)
if dragbox_rect.has_point(position_in_2d):
selected_array.append(object)
return selected_array
The other “Builder” entity does have a @onready var and it being called into the script
##Onready
@onready var obj_selected_indicator: Sprite3D = $Selected_indicator
## consts
const DRAGBOX_MIN_SIZE:int = 1
const SCRIPT_DEFAULT_SELECTION:Script = preload("../builder_control/builder.gd")
## exports
## public var
## private var
## onready var
@onready var obj_ui_dragbox: NinePatchRect = $NinePatchRect
@onready var obj_default_selection: SCRIPT_DEFAULT_SELECTION = $"../Builder"