Drag and drop, potion mix game

hi, im making a drag and drop game, it’s like mixing elements to make a potion, but i have several combinations… do you have tips/suggestions so i can achieve that? here’s my events editor:

I love the concept. I went on a bit.

I see 2 paths. You can use separate objects put into a group for each element or 1 object with every animation.

You could then either place the element object on the slots or change the animation of the slot using either the object name or its animation and delete the object. It would be a lot like an inventory system.

When you click the mix button you can add the slot animation name or the name of the object in collision with the slot to create the combined name like salt + water = saltwater

You could then either create an object using the new name from a group or create an object and change the animation name to saltwater.

You could use a structure variable to check for valid combinations using the child exist condition.

Does child slot1 animation name plus slot2 animation name of variable named potions exist.

You could have a another event that could check if child slot2 plus slot1 exists so it wouldn’t matter which slot the elements were in.

It would be pretty efficient because it wouldn’t need separate events for each item plus, it wouldn’t matter if the element was water or a combined salt water. It could further mix them like salt water plus mushrooms or something.

thanks, but could you make an example? i can’t visualize it since im a newbie, and i haven’t used those conditions/functions yet

1 Like

Yes, I can. I already played with the concept a bit to test my idea.

1 Like

here’s my preview:

can you show how did you make it? im actually doing it for an school project

this is how i did it…

I wish I had known this was homework. Here’s a version similar to yours not using a variable. Your version was close. The only issue is the OR condition. I’m assuming you’re using the drag behavior.

Both OR conditions get checked even if one of them is true. So, if object isn’t in the slot that is used in the put around action then it doesn’t get picked. If it’s not picked then it can’t be used in the put around action. So, you need to either pick the slot in the condition or in the action. It’s clearer when done in the action.

if you drop water in slot 2,
is water in collision with slot 1 no, don’t pick slot 1
is water in collision with slot 2 yes, pick slot 2
So, now slot2 is in the pick list but slot1 is not in the pick list.
If the object isn’t in the pick list, then it can’t be used in the put around action

try me:
https://games.gdevelop-app.com/game-349f3cad-4d72-40f7-9fbf-147a095c25a2/index.html

This can be simplified with groups but I don’t know if you’ve learned about them yet.

1 Like

it worked! thank you! anyway i just wanna ask if should i copy those events and apply to all?
because the mechanics of the game is i need to create 4 solutions only and the rest for combining the objects would result to combustion or emulsion (failed)

and this is how the scene would look like…

The easiest way might be to add a scene variable like success then if the mix is good then set it to true. If it’s false then you can do something. Just set it to false when the button is clicked and then true if the mix is good.

This is going to really grow in size unless the objects are in groups but I don’t know the assignment or if you’re aware of the group feature.

1 Like

thank youu! this is how i did it: it only works for “saltwater” maybe there’s something i didnt do correctly

The success Boolean for water and oil is set to false but the others should work.
You would need to modify the drop part as well so it put the objects into the correct slots.

1 Like

drop part? is that the slot?

Yes, the first part here would need to have an event group for each object. That would guarantee the objects were in the correct order. Otherwise, you’d need to check both directions.

1 Like

i’ll tryyyyyyyyyyyy thatttt

good luck. I’ll be away from my PC. But there are others here who may be able to help. Later.

1 Like