0 votes

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?

in Engine by (265 points)

1 Answer

0 votes
Best answer

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.

by (265 points)
edited by

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', getpropertylist() 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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.