carenalgas / popochiu

Godot plugin to make point n' click games in a similar way to tools like Adventure Game Studio and Power Quest.
MIT License
159 stars 17 forks source link

Character InteractionPolygon is reset when reloading Aseprite file or running game #158

Closed drbloop closed 5 months ago

drbloop commented 5 months ago

Bug description

When importing a Character via Aseprite, the InteractionPolygon is reset to a default value. This causes the interaction area for a character to be the default small square in the middle of their sprite. This does not happen for other import types like Props in a Room.

I can see this happening by running git diff on the Character tscn after reloading Import or running the game and seeing the polygon coordinates have changed.

--- a/game/characters/manny/character_manny.tscn
+++ b/game/characters/manny/character_manny.tscn
@@ -218,7 +218,7 @@ metadata/_popochiu_aseprite_config_ = {

 [node name="InteractionPolygon" type="CollisionPolygon2D" parent="."]
 visible = false
-polygon = PackedVector2Array(-9.75, -14, 11.5, -12.75, 14.25, 16.25, -9, 15.5)
+polygon = PackedVector2Array(-10, -10, 10, -10, 10, 10, -10, 10)

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a Character and import from Aseprite file
  2. Update the InteractionPolygon for the Character in its scene
  3. Add the Character to a Room
  4. Run the Room scene and try to click on the Character

Expected vs observed behavior

I expected the InteractionPolygon would be what I set in the Character scene, but it is instead the small default square.

Environment information (please complete):

Additional context

I only noticed this when moving to new Aseprite import workflow for Characters, so maybe the problem is in the import code. Previous Characters created without Aseprite import have correct InteractionPolygon boxes in Rooms.

drbloop commented 5 months ago

I was able to get around this issue by manually editing the Character tscn file in a text editor. It looks like the InteractionPolygon array of points is declared twice in the file, and unless you edit them both to be the correct value, the InteractionPolygon defaults to the small square.

[node name="CharacterSabrina" type="Area2D"]
priority = 1
script = ExtResource("1_fq3jt")
text_color = Color(0.47451, 0.227451, 0.501961, 1)
can_move = false
popochiu_placeholder = null
script_name = "Sabrina"
description = "Sabrina"
walk_to_point = Vector2(-58, 57)
cursor = 8
interaction_polygon = PackedVector2Array(-19, -65, 26, -65, 22, 15, -17, 16)
...
[node name="InteractionPolygon" type="CollisionPolygon2D" parent="."]
visible = false
polygon = PackedVector2Array(-19, -65, 26, -65, 22, 15, -17, 16)
...

Maybe there is a way to reference the InteractionPolygon in the Character node instead of duplicating it - then there would be a single source of truth.

mapedorr commented 5 months ago

Will be fixed with #163