Issue: Incorrect Positioning of AnswerGroup Objects in GDevelop
Description
I’m encountering an issue in GDevelop where I need to position each AnswerGroup object to the corresponding position of BlankGroup objects. However, when I click on an AnswerGroup object, all of them move to the position of the last BlankGroup object, rather than their intended individual positions.
Steps to Reproduce
Create multiple instances of AnswerGroup and BlankGroup.
Set up an event to move AnswerGroup objects to the positions of BlankGroup objects upon clicking.
Current Event Setup
Here is the current setup in GDevelop:
Repeat for each instance of AnswerGroup:
Repeat for each instance of BlankGroup:
Conditions:
The cursor/touch is on AnswerGroup
The left mouse button was released
Trigger once
Actions:
Tween the position of AnswerGroup to x: BlankGroup.PointX("Center"), y: BlankGroup.PointY("Center") with easing "bounce" over 1 second as "Draggable"
Problem
When I click on an AnswerGroup object, all AnswerGroup objects move to the position of the last BlankGroup object instead of their respective positions.
Expected Behavior
Each AnswerGroup object should move to the corresponding BlankGroup position individually upon clicking.
Request
Can anyone suggest how to correctly set up the events so that each AnswerGroup object moves to its respective BlankGroup position?
You can give your Blank objects a number variable. If your BlankGroup objects are laid out by you in the scene editor, you can click each object and modify that variable to be 1, 2, 3, 4, 5 etc.
For your AnswerGroup, you can give them a number variable too with a default value of 0.
In events you will make a counter that keeps track every time you are about to move an Answer. In my example I made a scene number variable for the counter and I gave it a default value of 0 because I will add 1 the first time it is used and each time after.
If your Blanks and Answer are something the player can generate into the scene and not something you have laid out in the scene editor, the principle is the same. You will make a scene variable counter for Blanks and increase this by one every time the player creates the object, then change the object ID to this counter number. When they create Answers you will leave the default ID at 0 but keep another scene counter for AnswerID and increase when the player clicks an answer.
Anyway that’s one way I’m sure there are a lot more.
Trigger once isn’t needed on a mouse release event because you can only release the mouse once at a time.
Sometimes For Each Object is not needed because you are explicitly telling the engine which object - THIS object I just mouse released to THAT object with the same ID.
I wanted to take a moment to express my sincere gratitude for your prompt and thorough response to my recent issue. Your assistance and expertise have been invaluable in helping me navigate through the problem.
I want to implement a functionality where, when I click on a blank and select an answer, the selected answer will be placed into the blank. Each answer will have a variable corresponding to each blank. If the answer matches the blank, it will be considered correct and will add 100 coins. If the answer is incorrect, it will remain the same and cannot be selected again. Additionally, each blank can only have one answer chosen for it.