How can I access the "Spatial" in MeshInstance?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: 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)

:bust_in_silhouette: Reply From: GameVisitor

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 :slight_smile:

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


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 ?

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.

kidscancode | 2019-04-07 23:10

It really helped, thank you very much!

PiggyPigginton | 2019-04-08 18:39