Topic was automatically imported from the old Question2Answer platform.
Asked By
PiggyPigginton
If I add a MeshInstance to my scene, there is a “Spatial”-section in the inspector, how can I access the translation for example?
Picture: Imgur: The magic of the Internet
(I am using GDScript btw)
MeshInstance inherits from Spatial class, you don’t have to “get” the spatial object, you can directly access Spatial methods as described here.
ex: node.get_translation()
hope this helps
You don’t need to use get/set - in fact, the autocompletion ignores it. Instead, the preferred method is direct property access:
var t = node.translation
or
node.translation = Vector3(0, 0, 0)
See the “Properties” section on each node’s API page. Also, that link was to the 3.0 version of the docs, which may be missing some things if you’re using 3.1.
kidscancode | 2019-04-07 16:58
I updated the links in my reply, but is there any performance benefit for direct access (to be the preferred one) or just programming style ?
Thx.
GameVisitor | 2019-04-07 17:55
I don’t believe there’s any performance difference, although I’d be surprised if there were. It’s mainly coding style, but the coding style that the engine prefers. Autocomplete is a very useful tool.