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

You can no longer cut holes in Polygon2Ds. #86242

Closed
TheFoxKnocks opened this issue Dec 16, 2023 · 5 comments
Closed

You can no longer cut holes in Polygon2Ds. #86242

TheFoxKnocks opened this issue Dec 16, 2023 · 5 comments

Comments

@TheFoxKnocks
Copy link

Tested versions

v4.2.1.stable.official [b09f793]

System information

Godot v4.2.1.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3080 (NVIDIA; 31.0.15.3623) - 12th Gen Intel(R) Core(TM) i9-12900KF (24 Threads)

Issue description

When creating a Polygon2D (including NavigationPolygon2D), you can create a large area and then cut parts of the center out by creating more polygons inside. The documentation also implies this is how it works and indeed is exactly how it worked in 4.1.

polygon

In this case, however, what was previously working now seemingly does nothing and is ignored. The cyan area is a NavigationPolygon2D and I cut out an area for the base of the tree. As you can see, the Polygon2D continues into the tree despite this area created.

This is not how it behaved in 4.1.

Steps to reproduce

Explaind above.

Minimal reproduction project (MRP)

N/A

@TheFoxKnocks
Copy link
Author

As an addendum, when using a Polygon2D specifically, any time you try to create a new area within an already defined Polygon2D in order to cut a hole out, it instead replaces the entire Polygon2D.

@smix8
Copy link
Contributor

smix8 commented Dec 16, 2023

You never could create "holes" with the Polygon2D editor draw tools.

What changed is the 2D navigation mesh baking with NavigationPolygon and NavigationRegion2D.

Nested outline support ("holes") was dropped, if you need "holes" add obstructions for the baking process to parse ,e.g. StaticBody2D or Polygon2D nodes that should "cut" into the navigation mesh with their shapes.

For compatibility the old outlines where kept but if you want the old bake behavior you need to call the deprecated function NavigationPolygon.make_polygons_from_outline() manually in script.

The documentation was updated to reflect that, although only recently. It has not yet been back ported to the 4.2 release branch so you only see it in the latest and 4.3 documentation branch. https://docs.godotengine.org/en/latest/tutorials/navigation/navigation_using_navigationmeshes.html

@TheFoxKnocks
Copy link
Author

You never could create "holes" with the Polygon2D editor draw tools.

What changed is the 2D navigation mesh baking with NavigationPolygon and NavigationRegion2D.

Nested outline support ("holes") was dropped, if you need "holes" add obstructions for the baking process to parse ,e.g. StaticBody2D or Polygon2D nodes that should "cut" into the navigation mesh with their shapes.

For compatibility the old outlines where kept but if you want the old bake behavior you need to call the deprecated function NavigationPolygon.make_polygons_from_outline() manually in script.

The documentation was updated to reflect that, although only recently. It has not yet been back ported to the 4.2 release branch so you only see it in the latest and 4.3 documentation branch. https://docs.godotengine.org/en/latest/tutorials/navigation/navigation_using_navigationmeshes.html

Oh I see! Very cool. I was apparently looking at the wrong docs because that wasn't familiar to me, but I now understand how to really use baking. Thank you!

For regular Polygon2D's, you may be right. What could I do for this? I have a Polygon2D that basically holds where enemies can spawn, but I don't want them spawning in trees or other such obstacles so I need a way to cut around those. This clearly uses a different technique as no baking is available there, so what do you recommend I do to handle this?

@smix8
Copy link
Contributor

smix8 commented Dec 16, 2023

A real polygon can not have a "hole", so what you basically always do is turn it into 2 or more polygons that are placed around your empty space ("hole"). That is also what the debug rendering does behind the scene when you draw outline paths with the editor tools.

@smix8
Copy link
Contributor

smix8 commented May 8, 2024

Closing as there is not bug or regression here and for a "hole" feature with Polygon2D there are (multiple) proposals like godotengine/godot-proposals#9127 open to track it.

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

No branches or pull requests

3 participants