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

Painting a rotated or flipped tile in a Tilemap loses collision #83825

Closed
warriormaster12 opened this issue Oct 23, 2023 · 10 comments · Fixed by #84660
Closed

Painting a rotated or flipped tile in a Tilemap loses collision #83825

warriormaster12 opened this issue Oct 23, 2023 · 10 comments · Fixed by #84660

Comments

@warriormaster12
Copy link
Contributor

Godot version

4.2 beta 2

System information

Pop Os 22.04 lts 12th Gen Intel® Core™ i7-12700H × 20 NVIDIA RTX A2000 8GB 32.0  ram. Tested on Forward+ and Mobile

Issue description

When painting a tile that is rotated or flipped, it looses its physics layer as demonstrated in this video:

2023-10-23.10-30-26.mp4

Even though in the video I showed this only happening with one of the tiles, it happens with both of them as long as you rotate or flip it.

Steps to reproduce

  1. Create a tilemap and a tileset
  2. Create a physics layer and set collision_visibility_mode to force show.
  3. Assign just created physics layer to tiles
  4. Paint the tiles and use rotate or flip tool.

Minimal reproduction project

TileTest.zip

@akien-mga
Copy link
Member

CC @KoBeWi @groud

@KoBeWi
Copy link
Member

KoBeWi commented Oct 23, 2023

Looks like editor-only bug. The tiles have correct collisions at runtime.

@warriormaster12
Copy link
Contributor Author

Only if you load the level directly. Calling get_tree().change_scene_from_file() breaks the collision.

@warriormaster12
Copy link
Contributor Author

Should have mentioned that

@KoBeWi
Copy link
Member

KoBeWi commented Oct 23, 2023

Your minimal project is a bit incomplete; you have a script for changing scenes, but it's not attached anywhere.
Anyway, I was able to reproduce the bug.

@warriormaster12
Copy link
Contributor Author

I originally intended to include a scene where you switch scenes because I thought that the issue was related to loading a scene. When I was able to produce the bug in the editor, I decided to delete the scene but forgot to do the same with the script.

Clearly I should have kept it and mentioned it.

@dehboxturtle
Copy link

dehboxturtle commented Oct 23, 2023

I just saw this after I had opened a similar ticket here. #83849

Mine has a minimal project that switches scenes and shows the breakage if you want to use that. Otherwise feel free to close the duplicate.

@KoBeWi
Copy link
Member

KoBeWi commented Oct 23, 2023

Removing this line fixes the issue:

polygon_cache.clear();

Just as I feared in #80144 (comment), clearing cache at an arbitrary point will invalidate some polygons that are still in use. As a quick-fix we could remove this line at runtime to fix scene changing bug, not sure about the editor fix.

@dehboxturtle
Copy link

MRP for anyone else who needs it
missing collisions.zip

Repro steps:

  1. Start game on Scene 1
  2. step on the scene switch trigger in scene 1 to go to scene 2
  3. Switch back to Scene 1 from Scene 2 via the scene switch trigger and observe collision boxes missing from rotated/flipped tiles.

@akien-mga akien-mga changed the title Painting a rotated or flipped tile in a Tilemap looses collision Painting a rotated or flipped tile in a Tilemap loses collision Nov 14, 2023
@akien-mga akien-mga modified the milestones: 4.2, 4.3 Nov 14, 2023
@groud
Copy link
Member

groud commented Nov 15, 2023

Closing as fixed by #84261

@groud groud closed this as completed Nov 15, 2023
@AThousandShips AThousandShips modified the milestones: 4.3, 4.2 Nov 15, 2023
@akien-mga akien-mga modified the milestones: 4.2, 4.3 Dec 14, 2023
@akien-mga akien-mga modified the milestones: 4.2, 4.3 Dec 14, 2023
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.

6 participants