Dynamically Created CSGBox with no Collision

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


I’m trying to generate a random 3d dungeon build out of rooms.

My room is spatial node, with a floor and 4 walls made of CSGBox instances, and a Door CSGBox with subtraction to make a basic hole in the wall.

Basic structure:

  • CSGBox Floor
  • Spatial Walls
    • CSGBox Walls 1-4

I’m making a script to dynamically generate rooms, and when I add another room to the scene at runtime, I fall through the floor.

Example Code:

var room_path = “res://Rooms/Room 3.tscn”
var room_scene = load(room_path)
var room_instance = room_scene.instance()
// Move the instance around to connect it to another room

Is there something I need to call to enable collision for my dynamically created room instance?

:bust_in_silhouette: Reply From: Aaron Westbrook

Whoops! Turns out I was adding my room as a child of a “Node” type. If I put it under a spatial, it works just fine!