I’m currently using godot 4.3 to create a rougelike and I’m randomly generating rooms. I’m trying to get the exits to randomly open and close unless the target room has one already. This is what I have:
extends Node2D
var ConnectedSides
var BlockedExits : Array = []
var Connections = 0
func _on_up_detector_area_entered(area: Area2D) -> void:
if area.name == "DownDetector" and await BlockExit(area):
$BlockedExitUp.visible = false
$BlockedExitUp.enabled = false
$RoomExitUp.enabled = true
$RoomExitUp.visible = true
func _on_left_detector_area_entered(area: Area2D) -> void:
if area.name == "RightDetector" and await BlockExit(area):
$BlockedExitLeft.visible = false
$BlockedExitLeft.enabled = false
$RoomExitLeft.enabled = true
$RoomExitLeft.visible = true
func BlockExit(Exit: Area2D):
if Exit.get_parent().Connections >= 3 or Connections >= 3:
var RngDoor = randi_range(1,10)
if RngDoor == 1:
Exit.get_parent().Connections += 1
return true
else:
return false
else:
Exit.get_parent().Connections += 1
return true
func OpenExits():
pass
func _on_right_detector_area_entered(area: Area2D) -> void:
if area.name == "LeftDetector" and await BlockExit(area):
$BlockedExitRight.visible = false
$BlockedExitRight.enabled = false
$RoomExitRight.enabled = true
$RoomExitRight.visible = true
func _on_down_detector_area_entered(area: Area2D) -> void:
if area.name == "UpDetector" and await BlockExit(area):
$BlockedExitDown.visible = false
$BlockedExitDown.enabled = false
$RoomExitDown.enabled = true
$RoomExitDown.visible = true
The problem is a lot of the time one of the doors is open while the other is closed. If you could help, that’d be great!