How do get the collisionshape of a TileMap

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By reggie

I’ve searched everywhere but i cant seem to find anything about getting the collisionshape of a TileMap.

:bust_in_silhouette: Reply From: kidscancode

You can’t get this from the TileMap, it’s not exposed to the API. What are you trying to accomplish?

If you must have a shape, you can make the TileMap the child of a CollisionObject2D and set collision_use_parent, and the parent object will have a polygon collision shape created and added to it.

is the new polygon collision shape added as a child to the parent?

reggie | 2021-03-13 01:48

Yes, for example, if you had a StaticBody2D with a TileMap child, setting collision_use_parent would give the StaticBody2D a collision polygon shape.

kidscancode | 2021-03-13 02:24