Get InstancePlaceholder position

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By gnumaru

The InstancePlaceholder node is a direct child of Node, so it doesn’t have an inherited properties like position, translation or transform. Likewise, there is no documented property or method for getting an instance placeholder’s position. So, how do you get the position of a placeholder for a Control, Node2D or Spatial?

:bust_in_silhouette: Reply From: gnumaru

TL;DR: InstancePlaceholder has an undocumented ‘position’ property with the local position.

By debugging and searching on the returned values of get_meta_list(), get_property_list() and get_method_list() I could notice there is an undocumented property called ‘position’. Since I’m doing an InstancePlaceholder for a Node2D, this property has a Vector2 value. I suppose it would be a Vector3 for a Spatial, and maybe something else for a control node.

I just noticed that this property exists only when it its not a default value. If the node’s position is (0,0), the position property will not ‘exist’, get_property_list() will not return it, “‘position’ in object” will return false and if you try to access it, it will yield an ‘invalid get index’ error. This also happens with scale, and probably other properties too. probably this is the way an instance placeholder works. It will store whatever non default property you set in the inspector and create dynamic properties for it.

gnumaru | 2022-02-01 09:15