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

WorldBoundaryShape2D doesn't work when moving a little farther than 11000px away #76917

Closed
hsandt opened this issue May 10, 2023 · 6 comments · Fixed by #90763
Closed

WorldBoundaryShape2D doesn't work when moving a little farther than 11000px away #76917

hsandt opened this issue May 10, 2023 · 6 comments · Fixed by #90763

Comments

@hsandt
Copy link
Contributor

hsandt commented May 10, 2023

Godot version

v4.0.2.stable.official [7a0977c]

System information

Linux Ubuntu 22.04 with Unity desktop

Issue description

I'm using WorldBoundaryShape2D to delimit my level area and noticed that at some point, the character can leave the delimited area. I identified the collider to stop working around 11000px away from the center of the WorldBoundaryShape2D, in the tangent direction.

The distance is not as crazy as it seems, esp. when working on a runner-style game where the player character moves in the world (and not the reverse, i.e. obstacles are not coming at the player as some shmups do).

If there are technical reasons for the limitation, then this should be documented so users know they must regularly repeat adding the WorldBoundaryShape2D.

Steps to reproduce

  1. In the MWE attached, I setup a WorldBoundaryShape2D at the origin and several sprites marking milestones of 1000px away from the origin each. The player character is placed near the 11000 milestone to make it easier to test. Also, it is affected by gravity.
  2. Run the demo and move right a little beyond the 11000 milestone with the right key.
    Expected: character keeps moving on the ground delimited by WorldBoundaryShape2D
    Actual: character falls into the ground shortly after the 11000 milestone

Godot 4 0 2 - WorldBoundaryShape2D stops after 11000px

Minimal reproduction project

Godot 4.0.2 - WorldBoundaryShape2D doesn't work when very far.zip

@Calinou
Copy link
Member

Calinou commented May 10, 2023

Can you reproduce this in 3D?

hsandt added a commit to hsandt/ld53 that referenced this issue May 10, 2023
@rburing
Copy link
Member

rburing commented May 11, 2023

Indeed, here is the AABB of the shape:

configure(Rect2(Vector2(-1e4, -1e4), Vector2(1e4 * 2, 1e4 * 2)));

The same in 3D:

configure(AABB(Vector3(-1e4, -1e4, -1e4), Vector3(1e4 * 2, 1e4 * 2, 1e4 * 2)));

😅

@Calinou
Copy link
Member

Calinou commented May 11, 2023

Are there any negative consequences to increasing this AABB to much higher values like +1,048,576 (in single precision builds) and ~10 billion (in double precision builds)? Would it make the collision less precise around the plane (i.e. "snapping" to coordinates)?

@awardell
Copy link
Contributor

It seems odd for WorldBoundaryShape2D to have an AABB, considering it is supposedly "infinite". I suppose it has to in order to be a shape, but ideally there would be some way to make the physics server disregard that and just always test. There will almost never be more than 4 WorldBoundaryShape2D at max, and even for angled ones the collision test is trivial.

As is currently, the WorldBoundaryShape2D is somewhat useless for its intended purpose.

@am4sten
Copy link

am4sten commented Dec 25, 2023

Yeah I stumbled upon the same issue in a side scrolling project on 4.2, it seems that the workaround would be spawning collision shapes every 11k px-ish but not sure how it's sustainable or how the physics server is gonna handle all of that after a while.

Then again, like @awardell said it does defeat the purpose of the WorldBoundaryShape2D/3D to have this kind of workaround.

PS : Happy holidays !!

@Rip50
Copy link

Rip50 commented Apr 11, 2024

Hit the same issue when working on my game. Is there any plans to make it actually infinite?

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