0 votes

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:
        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
        for door in Doors:

func _open_theatre_door(door):
    var currentDoor = get_node("Doors/" + door)
    old_layer_mask = currentDoor.get_node("StaticBody2D").get_layer_mask()
    old_collision_mask = currentDoor.get_node("StaticBody2D").get_collision_mask()
    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.

in Engine by (296 points)
edited by

Did you make sure the collision masks are properly restored as you expect when crossing the door again?

Yeah and the collision mask are only changed for the static body to allow the character to move through, so this shouldn't affect the area2d right?

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.