I am working on a 2D action game where I would like the player to sometimes hide in areas in the background. When I do that, I'd like the following things to happen
1) Take away all control inputs from the player, except moving down to come out of hiding
moving is done using the following lines of code
var direction = Input.get_axis("ui_left", "ui_right")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
and
if not is_on_floor():
velocity.y += gravity * delta
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
2) remove collision with enemies, but only enemies and not the floor so the player doesn't fall through the floor
I tried
get_node("CollisionShape2D").disabled = true
but this obviously removes all collision, including with the floor and my character just falls off the screen
What would be the best course of action to implement these elements? any help is appreciated