xyz Well thats where im having trouble. I got the top most Y (total_size.y
) with the existing meshes in the parent node. then add the picked up nodes AABB with size (total_size.y = total_size.y + p_aabb.size.y
). But somehow i cant get the offset.
When i calculate var result_y = total_size.y - picked_up_obj.item_mesh.global_transform.origin.y
it gives me the wrong offest.
So far i got this
var total_size:Vector3
var p_aabb = picked_up_obj.item_mesh.global_transform * picked_up_obj.item_mesh.get_aabb()
for n in hand_node.get_children():
if n is Item:
var child:Item = n
var mesh=child.item_mesh
var m_aabb = mesh.global_transform*mesh.get_aabb().abs()
total_size.y = max(total_size.y,m_aabb.end.y) - hand_node.global_position.y
var pp = PLANE.instantiate()
if hand_node.get_children().size() == 0:
hand_node.add_child(pp)
else:
hand_node.add_child(pp)
pp.position=total_size
total_size.y = total_size.y + p_aabb.size.y
var result_y = total_size.y - picked_up_obj.item_mesh.global_transform.origin.y
total_size.y = result_y