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

Reparenting a CharacterBody2D/TileMap duo to or from a SubViewport disables their collisions #83291

Closed
NewDefectus opened this issue Oct 13, 2023 · 2 comments · Fixed by #84968

Comments

@NewDefectus
Copy link
Contributor

NewDefectus commented Oct 13, 2023

Godot version

4.2.beta4

System information

Godot v4.2.beta4 - Windows 10.0.19045 - GLES3 (Compatibility) - Intel(R) UHD Graphics 620 (Intel Corporation; 31.0.101.2125) - Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz (8 Threads)

Issue description

Pretty much what the title says. Reparenting a common ancestor of a CharacterBody2D and a TileMap to or from a SubViewport will cause their collisions with each other not to work. Interestingly enough, changing the collision_animatable field of the TileMap - which I guess flushes its collision or something - after reparenting, fixes this issue.

To be sure, I've checked reparenting to a regular Node2D, and also to a plain Node - it seems that this bug is specific to reparenting to a SubViewport. I've also not had this issue with collision objects other than a TileMap (static collision objects for instance do not experience this bug).

Steps to reproduce

Attached below is a minimal reproduction project, with a CharacterBody2D moving up and down in a loop, and a tilemap containing two bars that block the CharacterBody2D's motion.

Pressing the down key reparents them to a SubViewport node, which is displayed on screen via a Sprite2D with a ViewportTexture (intentionally slightly smaller so you can distinguish the difference). If it's pressed again, the two are reparented back to their original node. You will notice that after pressing the down key, the CharacterBody2D will pass through the tilemap.

Pressing the up key will toggle the tilemap's collision_animatable flag, fixing the bug until the down key is pressed again.

Minimal reproduction project

tilemap_reparent_mrp.zip

@NewDefectus
Copy link
Contributor Author

If it helps whittle it down, this issue affects version 4.2-dev5 and onwards, not having appeared in previous releases.

@NewDefectus
Copy link
Contributor Author

To help further whittle it down, I've confirmed that it's specifically 5fef875 (#81070) that causes this :)

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