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

Area3D does not detect body_entered on StaticBody3D and RigidBody3D #74300

Open
nox123 opened this issue Mar 3, 2023 · 25 comments
Open

Area3D does not detect body_entered on StaticBody3D and RigidBody3D #74300

nox123 opened this issue Mar 3, 2023 · 25 comments

Comments

@nox123
Copy link

nox123 commented Mar 3, 2023


Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.


Godot version

Godot Engine v4.0.stable.official.92bee43ad

System information

Vulkan API 1.2.231 - Forward Mobile - Using Vulkan Device #0: Apple - Apple M1 Max

Issue description

Area3d not detect (or send signal) body_entered when BODY is StaticBody3d or RigidBody3d
it's detecting this object only when SB or RB starts in the area

CharacterBody3D is different case it is detected when it's entered, so it works properly

Steps to reproduce

-create Area3d with big colisionShape

  • create static body or rigidbody outsid of area3d
  • move SB oar RB away from area3d
  • set up layers and collisions
  • make object enter area

Minimal reproduction project

Area3dBug.zip

@AThousandShips
Copy link
Member

Related #66468

@AThousandShips
Copy link
Member

Have you set the area to monitorable?

@nox123
Copy link
Author

nox123 commented Mar 4, 2023

Yes

@TamerSoup625
Copy link

I'm also having this bug on v4.0.2.stable.official [7a0977c] with Windows 10 Home x64

I noticed that the area updates the overlapping bodies correctly if the area is moved or its parameters are updated, simirarly to #66468 where the area updates correctly with the change of collision layer/mask.

@TamerSoup625
Copy link

For those of you who want an hack against this bug, constantly changing the collision layer if you're using an Area3D node seems to work:

func _physics_process(delta):
	# Considering "area" an Area3D, and layer 32 an unused layer
	area.set_collision_layer_value(32, not area.get_collision_layer_value(32))

However it doesn't work if you're using servers for some reason, in which case it seems like only changing the monitorable property works:

func _called_every_physics_frame():
	# Considering "area" a RID pointing to a PhysicsServer3D area
	# Changing twice to ensure the monitorable property stays constant
	# If you want the area to be not monitorable, just swap places of the two lines of code
	PhysicsServer3D.area_set_monitorable(area, false)
	PhysicsServer3D.area_set_monitorable(area, true)

@JTimNolan
Copy link

Also having this bug.
Windows 10 Pro x64
Vulkan API 1.2.168 - Forward+ - GTX 780

@DennisManaa
Copy link
Contributor

DennisManaa commented Jul 1, 2023

I also can confirm this or at least a similar issue on
Ubuntu 22.04 x64
RTX 4090
Vulkan API 1.3.204
Forward+

@TamerSoup625's solution worked for me. I was using $Area3D.get_overlapping_bodies() for querying different non-moving physics-bodies. In my project it seems like the overlapping bodies aren't updated correctly during the physics step, when disabling and re-enabling a CollisionShape of a StaticBody3D which is inside of the Area3D (using the disabled-flag of the StaticBody3D).

Disabling seems to work correctly, but re-enabling a StaticBody3D inside of the Area3D seems to not be registered correctly by the Area3D.

Edit: The Area3D also was not moving. So none of the objects in my scene was moving.

@ee0pdt
Copy link

ee0pdt commented Jul 17, 2023

Same issue with RigidBody3D entering an Area3D on Mac in Godot 4.1

@coldi
Copy link

coldi commented Oct 8, 2023

I also ran into this issue with Godot .NET 4.1.2.
GetOverlappingBodies() doesn't work (calling it in _PhysicsProcess) and signals don't trigger either for StaticBody3Ds.
I've double checked all collision layers and masks.

I can confirm the Area3D works in the very first _PhysicsProcess step, but it does not report anything else during lifetime / doesn't detect any changes.

@matthewhilton
Copy link

matthewhilton commented Oct 14, 2023

Re the workaround by setting monitorable / collision mask - #74300 (comment)

Just discovered that neither of these work with Godot-jolt physics, and it has the same issue

@nulflux
Copy link

nulflux commented Nov 15, 2023

I'm piping in to add that this has been present since 4.0 at least. I don't believe it is limited to a certain type of node since this happened to me with a skeletal system inside a Node2D. I for whatever reason tried to change the root node to AnimationPlayer and poof the rig was gone. I learned not to change note types it's better to just create a brand new one. It is definitely a bug. This has been reported before and I think I commented on that one too.

@Calinou Calinou changed the title [Godot 4.0][Area3d]Area 3d dos not detect bodyEntered on StaticBody3d and RigidBody3d Area3D does not detect body_entered on StaticBody3D and RigidBody3D Nov 15, 2023
@My0Cents
Copy link

Using Godot 4.2 Beta 6 and I'm having the same issue.

@ChildLearningClub
Copy link

ChildLearningClub commented Dec 3, 2023

This made its way into 4.2 Stable
Godot Physics

2023-12-03.15-05-09.mp4

Same Scene With Jolt Physics

2023-12-03.15-05-38.mp4

MRP

@bdasuncion
Copy link

I have a similar situation in that I'm using a CharacterBody3d. During testing, when my CharacterBody3d isn't moving, the signal body_entered isn't triggered. When I put movement, then its triggered. Or similarly if it starts with the CharacterBody3d inside the Aread3d, then it is triggered as well

@richardathome
Copy link

I'm on 4.2.1 [b08f793f5] Windows 11 Home and experiencing this issue.

None of the fixes above worked for me. (detecting a RigidBody3D entering an static Area3D).

The only way I could get it to work is to jiggle the area 3d a tiny amount each _physics_process:

@onready var pos = global_position

func _physics_process(delta: float) -> void:
global_position = pos + Utils.random_vector3() * .001

@golddotasksquestions
Copy link

golddotasksquestions commented Jan 11, 2024

I just tested this with nox123 MRP in Godot 4.2.1 stable and 4.3 dev2 on Windows and can confirm the StaticBody3D issue, however RigidBody3D (and CharacterBody3D) seems to work as expected. I also tested different collision shape (BoxShape3D), but that did not any a difference.

@bikemurt
Copy link
Contributor

bikemurt commented Jan 27, 2024

I am also getting this bug in 4.2 but only when I preload a packed scene and then programmatically instantiate it at runtime. Doesn't matter if it is instantiated in _ready or _process, the area_entered/exited signals do not fire.

If I manually bring in an instance of that packed scene into my scene, the area3D signals work fine.

This may strongly hint that something is not getting initialized with the layers/masks/etc when being done programmatically.

Edit: but I should note that @TamerSoup625's suggestion above does not appear to fix it in this case (could be due to Jolt, however)... could be multiple bugs

Edit 2: figured out my problem (not an engine bug), but leaving this comment here because it may help someone else. My Area3D needed to be inside my RigidBody3D, because physics was acting on it and moving the object around. If the area3D is outside the RigidBody3D, then it gets "left behind" as the object moves.

@nicolasgustafsson
Copy link

nicolasgustafsson commented Jan 31, 2024

Got this issue with CharacterBody3D, after disabling the process mode(with Disable mode set to Remove) then reenabling it, and only rarely. Switching to Jolt-physics did not resolve it for me.

Using 4.2.1 stable

Following this did make it work for me, with Jolt too:

#74300 (comment)

@ScriptSlinger
Copy link

Got this issue with CharacterBody3D, after disabling the process mode(with Disable mode set to Remove) then reenabling it, and only rarely. Switching to Jolt-physics did not resolve it for me.

Using 4.2.1 stable

Following this did make it work for me, with Jolt too:

#74300 (comment)

You have to enable an option in Jolt settings. Took me 2 hours to find out.

@Kantrul
Copy link

Kantrul commented Mar 15, 2024

Got this issue with CharacterBody3D, after disabling the process mode(with Disable mode set to Remove) then reenabling it, and only rarely. Switching to Jolt-physics did not resolve it for me.
Using 4.2.1 stable
Following this did make it work for me, with Jolt too:

#74300 (comment)

You have to enable an option in Jolt settings. Took me 2 hours to find out.

For anyone using Jolt, the setting is in the project settings
imagen

@Pikari0
Copy link

Pikari0 commented Apr 6, 2024

Having this issue too, Godot 4.2.1 stable on Linux, not using Jolt.
If I use "change type" on an undetected StaticBody to change it to CharacterBody, suddently it's detected, and changing it back, it's undetected.

@rcjoel2019
Copy link

If you come by this and are spawning an Area3D to verify if it has a body inside it, the Area3D only sees what enter or exits of it, if you want to detect all bodies in a area (ex: during an explosion, searching all damageable bodies on that frame), you can check directly on the Physics server using:

var space := get_world_3d().direct_space_state
var search = PhysicsShapeQueryParameters3D.new()
search.transform = global_transform
var shape = SphereShape3D.new()
shape.radius = 4
search.shape = shape
var bodies = space.intersect_shape(search)

Check the docs on PhysicsDirectSpaceState3D for more details.

@emersonbottero
Copy link

For me it does not work only between instance of the same scene.
Tower can detect body_entered with wall but can't detect body_entered with another Tower.

@PickleOnAString
Copy link

still happening in 4.3 beta 1. i'm happy to try to fix this but don't know where to start

@EdgarPsda
Copy link

Hello everyone,
I'm not sure if this is a workaround or spected behavior but it works for me.
I have a RigidBody (Rock) that needs to dissapears when enter to Area3D (Portal), I created a Node3D as parent in the portal and inside the StaticBody and Area3D (This node will check if the rock of specific color entered), the portal has Node3D as parent to use the signal body_entered(Node3D) from Area3D.
PD: This only works if I set layer and mask on 2.
I shared a couple of images with my configuration and the behavior.
image
image
image

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