godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.09k stars 20.19k forks source link

Area2Ds are slow-ish at detecting bodies #92977

Open NormanTS1 opened 3 months ago

NormanTS1 commented 3 months ago

Tested versions

Reproducible in Godot v4.3.beta1

System information

Windows 11 - Godot v4.3.beta1 - OpenGL (Compatibility)

Issue description

I have a player for my Mario fan game, and i use staticbodies as blocks. To detect if the player is on the bottom side of a block, i use an area2d. The player can sprint; and when he hits the area2d's block on the edge in a specific pixel (probably) while sprinting, it doesn't bump.

If I don't sprint however, everything works just fine. So my theory is that the player hits and leaves the area so fast that the area2d below the block doesn't detect it immediately.

Steps to reproduce

  1. Make simple player for platfomer games (that can walk, jump, and run at least), and assign it to a group

  2. Make the question block using a staticbody2d and add an area2d under the block so that the player can interact with it from the bottom side.

  3. connect the area2d's _body_entered(body:Node2D) signal to the block script, and then write this:

    for player in get_tree().get_nodes_in_group("player_group_name"):
      if body == player:
        print("bump);
  4. Play the game and test it, by jumping to the edge of the block a few times until it doesn't print anything.

Here's a project i made rapidly that showcases the issue, i also added a footage inside the file so you can see how to achieve the problem.

area2d-issue.zip

AThousandShips commented 3 months ago

Please upload an MRP to make this easier to test:

NormanTS1 commented 3 months ago

working on it rn

NormanTS1 commented 3 months ago

is it okay if i show it with a footage?

AThousandShips commented 3 months ago

An MRP would be best but footage would help with the details

NormanTS1 commented 3 months ago

i'll send both

NormanTS1 commented 3 months ago

area2d-issue.zip

NormanTS1 commented 3 months ago

Here's the MRP, you can also find the footage inside the file

Calinou commented 3 months ago

@NormanTS1 In the future, please use the Edit button (located behind the icon in the top-right corner of your comments) instead of multi-posting.

NormanTS1 commented 3 months ago

Sure (if you mean for the mrp too, it's also in the main comment too

NormanTS1 commented 3 months ago

is there something i need to know? like, did you people experienced the bug?

NormanTS1 commented 3 months ago

i also tried changing the entire bump block system, but same results btw