[answered] Tilemap import: how can I create StaticBody2D using GDScript in the editor?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By colludium
:warning: Old Version Published before Godot 3 was released.

Hi. I’m trying to create a Tilemap import script (inspired by this question), but I’ve just reached the edge of my (limited) understanding of the editor. I can create a set of Sprites no problem, but how can I create a StaticBody2D sub-node and collision shape for each Sprite? The linked example demonstrates the creation code that is executed when a bool is clicked and that is what I have been modifying for my needs.

To create a static body 2d I have tried:

var newStaticBody = StaticBody2D.new()

…but nothing is created in the editor (aside from the sprites) and I can’t find a reference in the documentation. I would also like to automatically create a collision rectangle for each tile…

Can you please me offer me some advice on the best way to tackle this? Thanks.

I do not understand, you want to modify a Tileset resource that only have Sprites?

eons | 2017-04-29 16:04

:bust_in_silhouette: Reply From: colludium

Just for completeness here, I’ve just had this question answered. The problem was caused by trying to create the StaticBody2D node as a child of the Sprite. This did not work in the editor. However, creating the Sprite as a child of the StaticBody2D node works fine.