Overlapping CollisionShape2D hinders touch event from being fired

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sliks


I have a left button and right button for my game on my Android project using Godot 3.0. When the user press the left or right button, it will control the main character to move left or right. Here is the script for the right button.

func _on_RightButton_input_event(viewport, event, shape_idx):
if (event is InputEventScreenTouch || event is InputEventScreenDrag):
	if (event.pressed):
		emit_signal("right_btn_pressed", event)
		emit_signal("right_btn_released", event)

And this is the node structure of the right button:

    RightButton (Area2D)
       +CollisionShape2D (a circle)
       +Sprite (a right arrow image)

I also have some enemy spawning randomly on the scene. They move around and here is the script for the enemies

extends Node2D

enum MOVEMENT_TYPES{normal}
var movementType = MOVEMENT_TYPES.normal
export var motion = Vector2()
const UP = Vector2(0, -1)
var dyingBounce = true
var counter = 1

var enemyDie = false

func _physics_process(delta):
	if dyingBounce == true:
		motion.y = -100
		dyingBounce = false
	motion.y +=10
	if(movementType == MOVEMENT_TYPES.normal):
		motion = $Body.move_and_slide(motion, UP)
	var xf = Transform2D()
	xf[2]= motion * (delta * counter) 
	counter = counter - 2
	$Body.transform = xf

func hit_by_main_character():
    $Body.get_node("CollisionShape2D").disabled = true
    enemyDie = true
    pass # replace with function body

func _on_VisibilityNotifier2D_screen_exited():

And this is the node for the enemy:

        ColorRect (just a rectangle as a place holder)
        CollisionShape2D (also a rectangle)

Most of the time, the button works. However, when the enemy moves behind the right button, the right button will not detect the InputEventScreenTouch/fire the event properly. I am not sure if it is because of the overlapping CollisionShape2D, or some other issues. Please help. Any suggestions are welcome. Thank you!

:bust_in_silhouette: Reply From: sliks

Take me two whole days to figure it out. I am not sure why but the following config fixes the the issues.

In the colorRect under Enemy there is a “Mouse” section. Originally it was set to “stop”. Change it to “Ignore” fixes the issue.