i was trying to apply actions on specific elements of a group named "object", i have two rigidbodies in the group, i used for loop to iterate through group elements nd if distance between element and player is less than 4 actions will be applied, strangely not all actions gets applied, here is the code
extends Spatial
var axis
var kin
func _ready():
var rig1=$rig1
var rig2=$rig2
kin=$KinematicBody
axis=get_tree().get_nodes_in_group("object")
func _physics_process(delta):
for elem in axis:
if (kin.translation.distance_to(elem.translation)<4):
$Control.visible=true
if Input.is_action_just_pressed("ui_accept"):
$ItemList.add_item("tool",load("res://b65186fd210e34e35d0763332262993c.jpg"))
else:
$Control.visible=false
the visible property only changes with the last rigid body in the group, when i'm near the first element the button doesn't appear, what confuses me is that the nested if works with both of them, when i'm near first element it collects it nd when i'm near second element it collects it as well, so the code is calculating the distance between each one of them nd the player but i don't get why the button icon doesn't become visible with both, it only becomes visible when distance between last element of group object nd the player is less than 4, does anyone know why that might be?