func _physics_process(delta):
if Input.is_action_just_pressed("1"):
if $Area2D.has_overlapping_bodies():
one = false```
i try with only one of either "if" ,it works, i try with both ,even with"and",it doesn't, why such?
and `func _input(event: InputEvent) -> void:`doesn't work either ,for some reason if you were asking
Can you put print statements inside the if-clauses to check if they are being reached?
func _physics_process(delta):
if Input.is_action_just_pressed("1"):
print("1 is being pressed")
if $Area2D.has_overlapping_bodies():
print("Area has overlapping bodies")
one = false
Then check the output and see if something gets printed when you press 1
func _physics_process(delta):
if Input.is_action_just_pressed("1"):
print("1 is being pressed")
if $Area2D.has_overlapping_bodies():
print("Area has overlapping bodies")
one = false
if $Area2D.has_overlapping_bodies():
print("Area definitly has overlapping bodies")
This probably means that they are true at seperate frames. You can test it by doing this:
func _physics_process(delta):
print("New Frame!")
if Input.is_action_just_pressed("1"):
print("1 is being pressed")
if $Area2D.has_overlapping_bodies():
print("Area has overlapping bodies")
one = false
if $Area2D.has_overlapping_bodies():
print("Area definitly has overlapping bodies")
alirght i got a bad new and good new, the good one is that i found a solution, the bad one is that i lied about the good new…just kidding
here’s the solution:
func _physics_process(delta):
if Input.is_action_just_pressed("1"):
if one==true:
one = false
inspect()
func inspect():
if $Area2D.has_overlapping_bodies():
one = true
this is just a part of the code, not the whole code