Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

area_entered, area_exited occurs at the same time with Area2D #25331

Open
Tracked by #45334
volzhs opened this issue Jan 26, 2019 · 2 comments
Open
Tracked by #45334

area_entered, area_exited occurs at the same time with Area2D #25331

volzhs opened this issue Jan 26, 2019 · 2 comments
Assignees
Milestone

Comments

@volzhs
Copy link
Contributor

volzhs commented Jan 26, 2019

Godot version:

3.1.beta 973b68f

OS/device including version:

Kubuntu 18.10

Issue description:

area_entered and area_exited signal is propagated at the same time when setting Area.monitoring = true [or false]
only area_entered is expected when setting Area.monitoring = true and
only area_exited is expected when setting Area.monitoring = false

probably related to #22889

Steps to reproduce:

extends Node2D

func _ready():
	$on.connect("pressed", self, "monitor_on")
	$off.connect("pressed", self, "monitor_off")
	
	$area_ray.connect("area_entered", self, "on_area_entered")
	$area_ray.connect("area_exited", self, "on_area_exited")

func monitor_on():
	$area_box.monitoring = true

func monitor_off():
	$area_box.monitoring = false

func on_area_entered(area):
	printt("on_area_entered", area.name)

func on_area_exited(area):
	printt("on_area_exited", area.name)

area_enter_exit

Minimal reproduction project:

area monitor.zip

@reduz
Copy link
Member

reduz commented Jan 27, 2019

I think you are misunderstanding this issue. What you do here is toggling the "monitoring" property of box, while listen to areas that enter/exit ray.

What happens internally in the physics engine as you do this is that the object is added and removed from the space (this is needed so pairing can be re-created). As it is correct that the ray shape will sill monitor it, you get an exit/enter pair of signals.

The "bug" here may be that an optimization could be made within the physics to realize the area exited and entered and simply send nothing. Still the state remains correct.

IMO this is too low priority to fix now, as it's not exactly a bug, so kicking forward.

@reduz reduz modified the milestones: 3.1, 3.2 Jan 27, 2019
@akien-mga akien-mga added enhancement and removed bug labels Jan 27, 2019
@akien-mga akien-mga modified the milestones: 3.2, 4.0 Dec 13, 2019
@julsams
Copy link

julsams commented Nov 21, 2020

The "bug" here may be that an optimization could be made within the physics to realize the area exited and entered and simply send nothing. Still the state remains correct.

The solution you mention sounds incorrect as you describe it.
What if an object moves "fast" through a small area. The programmer/designer still expects to see that something entered and then exited that small area. Ignoring a pair of enter/exit is very confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants