So I have a 2d RPG game I am working on. I have a door animation when the player interacts with the door. The player can then walk through the door, which then shuts behind them. However, when I come back to the door the other way it isn't allowing me to interact with the door. I am using area2d on both the character and door to interact. I have two collision shapes within the area2d for the door, one at either side of the door, the one infront of the door works but the one on the far side doesn't.
Below is my script:
func _process(delta):
var playerPos = get_node("playerNode/Player").get_pos()
if playerPos.y <= 264:
for door in Doors:
door.set_z(1)
for door in doorShut:
if doorShut[door] == false:
get_node("Doors/" + door).set_frame(0)
get_node("Doors/" + door + "/StaticBody2D").set_layer_mask(old_layer_mask)
get_node("Doors/" + door + "/StaticBody2D").set_collision_mask(old_collision_mask)
doorShut[door] == true
else:
for door in Doors:
door.set_z(0)
func _open_theatre_door(door):
var currentDoor = get_node("Doors/" + door)
currentDoor.set_frame(1)
old_layer_mask = currentDoor.get_node("StaticBody2D").get_layer_mask()
old_collision_mask = currentDoor.get_node("StaticBody2D").get_collision_mask()
currentDoor.get_node("StaticBody2D").set_layer_mask(0)
currentDoor.get_node("StaticBody2D").set_collision_mask(0)
doorShut[door] = false
the opentheatre_door function is called when spacebar is pressed when the player is inside the area2d. If I go back round the bottom area always works, but the top never does, even if I try that interaction first.