Godot version:
Godot v3.2.2 stable win64
OS/device including version:
Windows 10 Home Version 2004
Issue description:
I have posted an explanation of the problem on readdit:
https://www.reddit.com/r/godot/comments/i0fanz/area2d_only_detecting_body_when_moving_around/
Additionally, I tried to copy over my scenes into a new project to see if it would happen again and the issue remained. A different project from before this issue appeared and a new project where I did not use any of the other scenes did not show this problem.
Steps to reproduce:
In the attached project, start the game, go close to one of the slimes using WASD and wiggle the game window around a bit with your mouse. The output should show a mix of messages with "Enter" and "Leave" printed a bunch of times. These prints come from the script attached to the PlayerDetector inside the SlimeBlue Scene.
Minimal reproduction project:
Death's Window.zip
Godot v4.2.2 stable win64
A bug report from the future :alien:
Little Update: I noticed that I am able to get the detection working with a fresh kinematic body with minimal nodes attached to make it function. The player still does not want to be detected though without a good wiggle of the game window.
I don't get any collision detected at all with your attached project, because the collision layer of the Player and the collision mask of the PlayerDetection Area2D node don't match.
I was trying out stuff with the layers to figure out what was wrong but I am quite sure I matched them again before making the zip. I saved and reproduced the error right before making the zip.
I was able to narrow down the cause of this error. Apparently, changing the parent of the player node causes the collision to fail. Within my WorldController node script I have the function move_player_to_world, which reparents the player node to a ySort:
player.get_parent().remove_child(player)
world.get_node("YSort").add_child(player)
It can be found inside the mentioned script at line 47.
Commenting it out, the collision works fine. Additionally, I can not run the remove_child() line by itself without an error, which I am uncertain if it is supposed to be like that (it would leave the player node without any parent).
So, hopefully final post:
I found that I reparented the player every _process() which seems to have caused this weird behavior.
Adding a warning or something when accidentally doing something like this might be good as finding the actual cause was quite a hassle. Cause and Effect did not seem correlated.
Most helpful comment
A bug report from the future :alien: