This is a super basic problem, I'm sure.
I'm using a gridmap for a tower-defence style game. I'm close to getting it to work, but can't get the building's ID to go through to the function that needs it.
I have 2 buttons for selecting which building to place.
func _on_Building_1_pressed():
is_building = true
building_ID = 0
func _on_Building_2_pressed():
is_building = true
building_ID = 1
This is the section of the _physics_process where the building_ID is called.
if is_building = true and Input.is_action_pressed("mouse_select"):
_place_building(building_ID)
if is_building = true and Input.is_action_pressed("mouse_cancel"):
is_building = false
This is the building placement code, which works fine if I manually set the ID to either 0 or 1
func _place_building(ID):
match ID:
0:
var building = building_1.instance()
building.translation = selection_position
$BuildingContainer.add_child(building)
1:
var building = building_2.instance()
building.translation = selection_position
$BuildingContainer.add_child(building)
map.set_cell_item(point.x, point.y, point.z, 90)
My question is how I let the _physics_process read the 'building_ID' from the button press functions. The 'is_building' bool is working just fine.
Thanks for taking the time to read, and have a lovely day.