Input.is_action_just_released & overlaps_area NOT WORKING TOGETHER

Godot Version

Godot v4.0.3

Question

Please help
I’m trying to have a thing when the left mouse button (“click” - assigned in input map) is released AND Areas_2d of both objects overlap.

Both “if” statements work PERFECTLY separately. This code worked BEFORE, one day I opened it and it just refuses to function.

Please tell me if there is something wrong with my code, or if its just a glitch.

func _process(_delta):
    if $Object/Area2D.overlaps_area($Another_Object) :
		if Input.is_action_just_released("click"):
			print("It works")

Any aid is greatly appreciated.

Add another print statement for the overlaps or us the debugger. The code seems fine, but I can’t say for sure all the conditions are met.

1 Like

Where is the code called? In process?

1 Like

Yeah, in process delta.

That’s the mindboggling part.
“It works #1” shows up just fine, but “It works #2” is absent:

func _process(_delta):
	if $Object/Area2D.overlaps_area($Another_Object) :
		print("It works #1")
		if Input.is_action_just_released("click"):
			print("It works #2")

And when I separate them like here, “It works” also shows up! :

func _process(_delta):
     if Input.is_action_just_released("click"):
			print("It works")

The just released function will only be valid in one frame,or process cycle, it could be that the area is overlapping is either only before or after the release.

1 Like

You are my savior, thank you so much!!!

I simply put await get_tree().create_timer(0.5).timeout

This allowed for the overlap to last a little longer giving enough time for the code to process the left mouse release signal WHILE both objects still overlapped.

You are absolutely correct!

I believe that at one point the project becomes way too big and everything begins to slow down with not enough time to go through a whole bunch of code.

You’re awesome! I cannot thank you enough!

1 Like

I think it would be better to use the _unhandled_input function and look for the click release event there instead of awaiting in the process.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.