Efficient Room Collision Shapes

Godot Version

v4.7.1.stable.official [a13da4feb]

Question

Is there a cheaper way to make a collision shape for rectangular rooms with entrance hallways? So far I’ve been making each wall of the room a separate SegmentShape, but I’m sure there must be a better way to do this.

Try StaticBody2D with a CollisionPolygon2D whose build_mode is set to segments.

Is there some way to put a hole in a CollisionPolygon2D? My character can’t walk out of the room anymore.

You can use ConcavePolygonShape2D. It’s like a bunch of segment shapes fused into one. The drawback is that you cannot visually edit it in the editor. You can generate it in code from your map data at runtime or in the editor using a tool script.

With a polygon node, you can try putting areas on doorways that nullify the wall collisions for anybody inside the area.

Also with tilemaps you can put colliders into wall tiles.