Unable to access dynamically added mesh using the SurfaceTool

UmaShankerUmaShanker Posts: 3Member
edited September 3 in 3D


I'm trying to create buildings procedural, [https://github.com/pjimenezmateo/procedural] , In the same code made small modifications like.. added the created mesh Instances to new group.

The following is the scene structure.

┖╴Spatial => Script Attached
┠╴Sun => Script Attached
┃ ┖╴Sky
┖╴piramidal0 => added dynamically.

Trying to access the mesh of the 'piramidal0' in the script that is attached to Sun... all it returns is null; even though mesh Object is present in the Scene.

More Info:
The mesh is created via Surface Tool and added to MeshInstance using surfacetool.commit

(https://github.com/pjimenezmateo/procedural "https://github.com/pjimenezmateo/procedural")

Tags :


  • Bean_B_BeanieBean_B_Beanie Posts: 2Member

    How are you trying to access the "piramidal0"? There are two methods I know of: using get_node and the short-hand notation $. These work locally, meaning that if you put get_node("piramidal0") or $piramidal0 into Sun's script, it would only look under Sun. Since Sky is the only child of Sun and not piramidal0, null is returned. To get piramidal0 from Sun's script, put get_node("../piramidal0") or $"../piramidal0". (As a note: if you use the short-hand notation as I have shown, you will need to enclose the path in quotes, or Godot will throw an error.)

  • MegalomaniakMegalomaniak Posts: 2,898Admin
    edited September 20

    There's also find_node and find_parent but since they're slower it is worth considering if you really need to use em.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file