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

Area2D's monitorable property does not seem to work when being set back to true #17330

Closed
stwupton opened this issue Mar 7, 2018 · 5 comments

Comments

@stwupton
Copy link

stwupton commented Mar 7, 2018

Godot version:
3.0.2-stable

OS/device including version:
Windows 10

Issue description:
When switching an Area2D's monitorable property to false, and then back to true, it continues to act as if it's set to false.

gd_monitorable_issue

Minimal reproduction
minimal.zip

The code is pretty much lifted from my actual project but in a simpler form.

Use the arrow keys to switch the disabled triggers (red) to enabled (blue). When one is enabled, all other triggers are set to disabled. When a trigger is enabled, the monitorable trigger is set to false and the opposite for the disabled triggers.

@NathanLovato
Copy link
Contributor

Confirmed, facing the same issue here.

@akien-mga akien-mga added this to the 3.1 milestone May 25, 2018
@AsixJin
Copy link

AsixJin commented Aug 25, 2018

I can confirm that this is still an issue in the latest version. Has anyone found a workaround?

@Goutte
Copy link
Contributor

Goutte commented Nov 9, 2018

I can confirm this with 3.0.6-stable on linux and windows.


For those who do not want to download the zip, here's my own minimalist project that makes it easy to see the bug.

Just hit Right once, hit Space twice, move around. No signal is sent anymore.
You can re-enable the signal by messing around, but I could not find a sure way to do it. Looks kinda random.
Note that monitoring appears to work just fine, the issue is with monitorable.

Scene.gd

extends Node

func _ready():
	$Area2D_A.connect('area_entered', self, 'on_area_a_entered')

func on_area_a_entered(area):
	prints('Area A entered', area)

func _input(event):	
	if event.is_action_pressed('ui_right'):
		$Area2D_A.position.x += 20
	if event.is_action_pressed('ui_left'):
		$Area2D_A.position.x -= 20
	if event.is_action_pressed('ui_accept'):
		$Area2D_B.monitorable = ! $Area2D_B.monitorable
		prints("$Area2D_B.monitorable", $Area2D_B.monitorable)

Scene.tscn

[gd_scene load_steps=3 format=2]

[ext_resource path="res://Scene.gd" type="Script" id=1]

[sub_resource type="RectangleShape2D" id=1]

custom_solver_bias = 0.0
extents = Vector2( 10, 10 )

[node name="Node" type="Node" index="0"]

script = ExtResource( 1 )

[node name="Area2D_A" type="Area2D" parent="." index="0"]

position = Vector2( 507.05, 295.665 )
input_pickable = true
gravity_vec = Vector2( 0, 1 )
gravity = 98.0
linear_damp = 0.1
angular_damp = 1.0
audio_bus_override = false
audio_bus_name = "Master"

[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D_A" index="0"]

shape = SubResource( 1 )

[node name="Area2D_B" type="Area2D" parent="." index="1"]

position = Vector2( 543.095, 303.911 )
input_pickable = true
gravity_vec = Vector2( 0, 1 )
gravity = 98.0
linear_damp = 0.1
angular_damp = 1.0
audio_bus_override = false
audio_bus_name = "Master"

[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D_B" index="0"]

shape = SubResource( 1 )

@Goutte
Copy link
Contributor

Goutte commented Nov 9, 2018

@AsixJin
As a (painful) workaround, you can handle the CollisionShape2D objects instead :

	if event.is_action_pressed('ui_accept'):
		var node = get_node('Area2D_B/CollisionShape2D')
		node.disabled = ! node.disabled
		prints("CollisionShape2D Disabled", node.disabled)

@Goutte
Copy link
Contributor

Goutte commented Nov 10, 2018

@AsixJin
Another workaround is to procedurally remove/add the Area2D from/to the scene tree, but it may yield unwanted side effects (such as signals, _ready, etc.), and it is slow.

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

Successfully merging a pull request may close this issue.

7 participants