feat: allow swapping item in slot #71

Merged
noahg merged 4 commits from noahg/allow-swapping-item-in-slot into dev 2026-04-10 08:53:41 +00:00
Member

Refactored interaction handling to be able to facilitate this three-way interaction coordination.
Refactored item slots so that their current item is automatically assigned from its child nodes.

Refactored interaction handling to be able to facilitate this three-way interaction coordination. Refactored item slots so that their current item is automatically assigned from its child nodes.
noahg self-assigned this 2026-04-10 03:25:57 +00:00
noahg requested review from xury 2026-04-10 03:26:04 +00:00
Owner

Thank you for putting this together, this already feels so much better for solving the sculpture puzzle, quickly being able to swap is great!

I did notice that's possible to display the wrong hint when too far away:

image

With the globe on the pedestal, and standing far enough away, the hint says "Pick Up" but if you press E you actually put your current held item down.

I'll keep looking at the rest of this PR :)

Edit: turns out this issue is not new to this PR, might be worth fixing at the same time, but it's also okay to save that for another time.

Thank you for putting this together, this already feels so much better for solving the sculpture puzzle, quickly being able to swap is great! I did notice that's possible to display the wrong hint when too far away: ![image](/attachments/bf29aab7-25f8-4b59-a03e-4118a50d019c) With the globe on the pedestal, and standing far enough away, the hint says "Pick Up" but if you press E you actually put your current held item down. I'll keep looking at the rest of this PR :) Edit: turns out this issue is not new to this PR, might be worth fixing at the same time, but it's also okay to save that for another time.
2.5 MiB
Owner

I haven't fond the exact way to reproduce this yet, but while shuffling around the children in editor I got this error a couple of times:
image

I haven't fond the exact way to reproduce this yet, but while shuffling around the children in editor I got this error a couple of times: ![image](/attachments/72c3ce3c-fbb2-41b5-9b01-b4d8679dff7a)
xury approved these changes 2026-04-10 06:18:53 +00:00
xury left a comment

This is looking really good, thank you for putting the work in on this it makes a big difference inside the editor and during game play!

Check my comments for a few minor areas of concern, I don't see any blocking issues though.

This is looking really good, thank you for putting the work in on this it makes a big difference inside the editor and during game play! Check my comments for a few minor areas of concern, I don't see any blocking issues though.
@ -8,0 +10,4 @@
_item_placement_marker = value
if _current_item and _item_placement_marker:
_current_item.transform = _item_placement_marker.transform
Owner

This is awesome! I wasn't expecting this feature, but it works really well!

This is awesome! I wasn't expecting this feature, but it works really well!
Author
Member

It was more of a workaround than a feature. I ended up finding a simpler solution that let me stick with @onready so I was able to eliminate this extra @export and other supporting logic.

It was more of a workaround than a feature. I ended up finding a simpler solution that let me stick with `@onready` so I was able to eliminate this extra `@export` and other supporting logic.
noahg marked this conversation as resolved
@ -11,0 +30,4 @@
assert(_item_placement_marker, "No Item Placement Marker assigned")
var pickup_items := _find_pickup_items_in_children()
assert(pickup_items.size() <= 1, "More than one PickupItem found in children")
Owner

I'm not sure which part of the code is responsible for this, but there's a small user experience issue:

In the current version, if I drag multiple PickupItems onto the ItemSlot, the first one it finds is snapped into the placement marker, but the others are left alone and it issues the assert.

While it's not valid to run the game in this state, the expected behavior would be that all of the items slot in, even though it issues the warning.

In my quick experimentation from a level design standpoint; I can tell this would be super useful for drag-and-dropping in any order I like, and fixing things as I go to take care of the asserts. But right now, if I drag in three, then move the first two, the final one is left behind, not snapped into place.

I'm not sure which part of the code is responsible for this, but there's a small user experience issue: In the current version, if I drag multiple PickupItems onto the ItemSlot, the first one it finds is snapped into the placement marker, but the others are left alone and it issues the assert. While it's not valid to run the game in this state, the expected behavior would be that all of the items slot in, even though it issues the warning. In my quick experimentation from a level design standpoint; I can tell this would be super useful for drag-and-dropping in any order I like, and fixing things as I go to take care of the asserts. But right now, if I drag in three, then move the first two, the final one is left behind, not snapped into place.
Author
Member

There was definitely a logic gap before. The weird behavior you identified should be fixed now.

There was definitely a logic gap before. The weird behavior you identified should be fixed now.
@ -11,0 +33,4 @@
assert(pickup_items.size() <= 1, "More than one PickupItem found in children")
if not pickup_items.is_empty():
place_item(pickup_items[0])
Owner

This line change seems like it was supposed to be part of the previous commit

This line change seems like it was supposed to be part of the previous commit
Author
Member

It definitely was. As I was cleaning this up I realized it should have done it differently anyway.

It definitely was. As I was cleaning this up I realized it should have done it differently anyway.
noahg marked this conversation as resolved
@ -11,0 +40,4 @@
str(
"Child PickupItem position is not equal to the Item Placement Marker position. ",
"This may have happened because the scene was edited outside the editor. ",
"Try unparenting and then reparenting the PickupItem to automatically place it back in the correct position.",
Owner

Using the method I described above, I was able to get into this state, but I did not see this assert trigger.
Also, upon reloading the scene / playing the level object snapped into place anyway.

I also tried getting it into this state, then making a build of the game, the built game also did not throw the assert, it just snapped the item into the slot. Not really an issue, I'm just not seeing this assert.

Using the method I described above, I was able to get into this state, but I did not see this assert trigger. Also, upon reloading the scene / playing the level object snapped into place anyway. I also tried getting it into this state, then making a build of the game, the built game also did not throw the assert, it just snapped the item into the slot. Not really an issue, I'm just not seeing this assert.
Author
Member

This should be sorted out now. Also, FYI asserts do not trigger in release builds of the game.
https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html#assert-keyword

This should be sorted out now. Also, FYI asserts do not trigger in release builds of the game. https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html#assert-keyword
@ -11,0 +50,4 @@
return
if _current_item and _item_placement_marker and not _current_item.position.is_equal_approx(_item_placement_marker.position):
_current_item.position = _item_placement_marker.position
Owner

This is probably fine, but I did notice you can try to use the gizmo, and it just detaches from the object, which is an odd behavior if you don't know what's going on. I wonder if there's a feature for locking the gizmos as well.

This is probably fine, but I did notice you can try to use the gizmo, and it just detaches from the object, which is an odd behavior if you don't know what's going on. I wonder if there's a feature for locking the gizmos as well.
Author
Member

I looked into how to go about solving this and there does not appear to be a simple way that doesn't come with new problems. The closest thing I could find was to lock the node by setting a special metadata flag, but that can still be defeated if you unlock it manually, so it's not a complete solution.

I looked into how to go about solving this and there does not appear to be a simple way that doesn't come with new problems. The closest thing I could find was to lock the node by setting a special metadata flag, but that can still be defeated if you unlock it manually, so it's not a complete solution.
@ -11,0 +79,4 @@
warnings.append(
str(
"This node requires exactly zero or one PickupItem child node. ",
"Please remove all extra PickupItem child nodes.",
Owner

Excellent!

Excellent!
noahg marked this conversation as resolved
noahg force-pushed noahg/allow-swapping-item-in-slot from c6f81a9ada to 643802ae09 2026-04-10 07:55:07 +00:00 Compare
Author
Member

@xury wrote in #71 (comment):

Thank you for putting this together, this already feels so much better for solving the sculpture puzzle, quickly being able to swap is great!

I did notice that's possible to display the wrong hint when too far away:

image

With the globe on the pedestal, and standing far enough away, the hint says "Pick Up" but if you press E you actually put your current held item down.

I'll keep looking at the rest of this PR :)

Edit: turns out this issue is not new to this PR, might be worth fixing at the same time, but it's also okay to save that for another time.

Fixing this would require a more involved reworking of how the interaction areas work and might even need the PickupItem objects to be aware of whether they are currently in a slot. The globe is a special case anyway, so I'm going to leave this as-is for now.

@xury wrote in https://git.bugjam.dev/BUGJam/pounce-game/pulls/71#issuecomment-952: > Thank you for putting this together, this already feels so much better for solving the sculpture puzzle, quickly being able to swap is great! > > I did notice that's possible to display the wrong hint when too far away: > > [![image](/attachments/bf29aab7-25f8-4b59-a03e-4118a50d019c)](/BUGJam/pounce-game/attachments/bf29aab7-25f8-4b59-a03e-4118a50d019c) > > With the globe on the pedestal, and standing far enough away, the hint says "Pick Up" but if you press E you actually put your current held item down. > > I'll keep looking at the rest of this PR :) > > Edit: turns out this issue is not new to this PR, might be worth fixing at the same time, but it's also okay to save that for another time. Fixing this would require a more involved reworking of how the interaction areas work and might even need the PickupItem objects to be aware of whether they are currently in a slot. The globe is a special case anyway, so I'm going to leave this as-is for now.
Author
Member

@xury wrote in #71 (comment):

I haven't fond the exact way to reproduce this yet, but while shuffling around the children in editor I got this error a couple of times: image

I haven't been able to reproduce this error. Maybe the project just needed to be reloaded first?

@xury wrote in https://git.bugjam.dev/BUGJam/pounce-game/pulls/71#issuecomment-954: > I haven't fond the exact way to reproduce this yet, but while shuffling around the children in editor I got this error a couple of times: [![image](/attachments/72c3ce3c-fbb2-41b5-9b01-b4d8679dff7a)](/BUGJam/pounce-game/attachments/72c3ce3c-fbb2-41b5-9b01-b4d8679dff7a) I haven't been able to reproduce this error. Maybe the project just needed to be reloaded first?
noahg requested review from xury 2026-04-10 08:05:01 +00:00
Owner

The new version has a couple of issues. I tried reloading Godot and deleting the .godot folder just to be sure.
I did encounter this:

image

This happened when I dragged three puzzle pieces from one pedestal to another at the same time.
It seems inconsistent though, not sure why it happens some times and not others.

Also, the assert to say there should be exactly zero or one item doesn't seem to be triggering anymore in this PR.

Edit: for posterity - both of these issues turned out to just be an issue where this class didn't reload correctly because it's a @tool - I just had to reload the editor.


Another thing I noticed: If you put all three correct puzzle pieces in place in the editor, I would expect the puzzle to register as solved when the game starts, but it doesn't you have to pick up one item and put it back down to get it to trigger.

The new version has a couple of issues. I tried reloading Godot and deleting the .godot folder just to be sure. I did encounter this: ![image](/attachments/d9e4a0b4-ba44-4dd1-84c7-37c3df181a8e) This happened when I dragged three puzzle pieces from one pedestal to another at the same time. It seems inconsistent though, not sure why it happens some times and not others. Also, the assert to say there should be exactly zero or one item doesn't seem to be triggering anymore in this PR. Edit: for posterity - both of these issues turned out to just be an issue where this class didn't reload correctly because it's a `@tool` - I just had to reload the editor. ----------------------- Another thing I noticed: If you put all three correct puzzle pieces in place in the editor, I would expect the puzzle to register as solved when the game starts, but it doesn't you have to pick up one item and put it back down to get it to trigger.
596 KiB
noahg force-pushed noahg/allow-swapping-item-in-slot from 643802ae09 to 5da154d07d 2026-04-10 08:43:21 +00:00 Compare
Author
Member

@xury wrote in #71 (comment):

The new version has a couple of issues. I tried reloading Godot and deleting the .godot folder just to be sure. I did encounter this:

image

This happened when I dragged three puzzle pieces from one pedestal to another at the same time. It seems inconsistent though, not sure why it happens some times and not others.

Also, the assert to say there should be exactly zero or one item doesn't seem to be triggering anymore in this PR.

Edit: for posterity - both of these issues turned out to just be an issue where this class didn't reload correctly because it's a @tool - I just had to reload the editor.

Another thing I noticed: If you put all three correct puzzle pieces in place in the editor, I would expect the puzzle to register as solved when the game starts, but it doesn't you have to pick up one item and put it back down to get it to trigger.

That error seems to be solved after reloading the project on my end.

The issue with setting the correct pieces not triggering the solution should now be resolved.

@xury wrote in https://git.bugjam.dev/BUGJam/pounce-game/pulls/71#issuecomment-970: > The new version has a couple of issues. I tried reloading Godot and deleting the .godot folder just to be sure. I did encounter this: > > [![image](/attachments/d9e4a0b4-ba44-4dd1-84c7-37c3df181a8e)](/BUGJam/pounce-game/attachments/d9e4a0b4-ba44-4dd1-84c7-37c3df181a8e) > > This happened when I dragged three puzzle pieces from one pedestal to another at the same time. It seems inconsistent though, not sure why it happens some times and not others. > > Also, the assert to say there should be exactly zero or one item doesn't seem to be triggering anymore in this PR. > > Edit: for posterity - both of these issues turned out to just be an issue where this class didn't reload correctly because it's a `@tool` - I just had to reload the editor. > > Another thing I noticed: If you put all three correct puzzle pieces in place in the editor, I would expect the puzzle to register as solved when the game starts, but it doesn't you have to pick up one item and put it back down to get it to trigger. That error seems to be solved after reloading the project on my end. The issue with setting the correct pieces not triggering the solution should now be resolved.
noahg deleted branch noahg/allow-swapping-item-in-slot 2026-04-10 08:53:42 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
BUGJam/pounce-game!71
No description provided.