-
Notifications
You must be signed in to change notification settings - Fork 69
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
Don't use CollisionGenerationMethod.Fast
in open shapes
#167
Don't use CollisionGenerationMethod.Fast
in open shapes
#167
Conversation
Not really a fix but a quick workaround. An actual fix would be to generate a closed curve. But I think this workaround suffices for the two people actually using open shapes. Edit: Just wanted to suggest to update the doc comment and suddenly a new commit is pushed :D |
2b6a0df
to
43c6e8c
Compare
Thanks for fixing! |
@mphe I actually use open shapes 😅 , but in a rather unusual manner - secret areas: |
How exactly? (hard to see on the picture) |
@mphe, I use smash-to-reveal areas like this: cover-demo.webm |
I've posted the code on discord some time ago - if you search for "secret area" you'll find it. |
Ahh ok, so there is an open shape with a closed one without edges attached. In such cases I usually use one shape and set material overrides on respective edges to "don't render". |
Not exactly, the cover is a Polygon2D with a script. @tool
## Script that manages a "cover" (see below). Updates are performed when transform is changed.
## It doesn't deal with rotations.
## Note: Not the full source code.
@export var sync_shape: SS2D_Shape
## `cover` is a Polygon2D that syncs its own fill texture to the SS2D's.
## It serves as an overlay that can be put on top of an SS2D and cover a "secret" area.
@onready var cover: Polygon2D = $Editable/Cover
func _notification(p_what: int) -> void:
if p_what == NOTIFICATION_TRANSFORM_CHANGED:
_update_cover_offset()
func _update_cover_offset() -> void:
if not sync_shape:
return
for i in cover.polygon.size():
cover.polygon[i] += cover.global_position
cover.global_position = Vector2.ZERO
var offset: Vector2 = sync_shape.global_position - cover.global_position
cover.global_position = sync_shape.global_position
for i in cover.polygon.size():
cover.polygon[i] -= offset |
Fixes #164