Snap Sprite Object To Another Sprite Object Only Once Per Sprite

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

How do I…

I am trying to make an educational game including an activity where the student needs to pick up sprite objects(individual words from a word bank) and place them in a particular sequence. My problem is that while trying to place the words by snapping them to placeholders(slots in my eventsheet), it is still possible to have duplicate logging of placement of individual words, thus leading to erroneous assessment of the student’s submitted word sequence.

I have implement the snapping and word placement mechanism by making all the placeholders and words into separate groups.

But, how do i ensure that the snapping and placement of words happens only once. Trigger once while true doesnt quite work. Here is how it goes in my eventsheet:

The game is multimedia heavy and so i am not sharing a link, but i can do so if needed. All help will be greatly sppreciated!

Here is the kind of action I’m trying to create:

I am not sure i get your issue
In this video you are moving US word to top left most free slot
And your issue is that it is how it should work
BUT you don’t want to allow now taking another word and put it into same exact slot
Cause its already occupied?

So like you cannot place words on slots that are already occupied?
IF so then i made it like 1 year ago for another user
I have hard time understanding now how it even works

So my suggestion is to just copy what you see
ALL tint actions are only visual representation that slot was used
They serve no functional purpose so you can delete them
And this system is buggy a little
Cause allows you to swap object you are dragging with object on which you drop dragged object BUT somehow you need to drag 2 objects 1st
IDK why there is this bug and why i did not fix it
HOWEVER i believe i made very convoluted way to do it
And for sure there is better way to do it


If that is not option for you
Then what you are asking is like base of inventory system so

Where this is 1st part of making inventory
But can push you in right direction

The problem i was having was having the logging of the orders of the words placed by the student happening multiple times. I solved it by deactivating the drag-gable behavior once it had taken its place. But now it poses another problem- allowing students to rearrange word sequences or order. To overcome this i am dynamically creating a “x” sprite which when clicked would return the word block to its original position.

But when i am actually clicking the cancel “x” button the whole WordBank group disappears. Here is the relevant part of my event sheet:

Any ideas?

For sure that condition the variable always is true needs trigger once
Cause you are spam creating cencelinput object

However i don’t understand now what is your issue and what you are trying to achieve

I am not sure if i am able expression myself clearly enough, but basically i want draggable words that snap to particular empty blanks when dragged nearby. Then if the player wants to, he or she can simply click on the cancel sprite or button to return it to its original position, before it was dragged. I have successfully implemented the first requirement, but am stuck at the second!

Put all your words into object group call it Words and add to that group 2 variables Xpos and Ypos

At beginning of the scene use repeat for each object and set for Words Xpos Words.X() and Ypos Words.Y()

Now when Words are in collision with cancel sprite and are not being dragged and cancel sprite is clicked
Change position of Words set to X Xpos Y Ypos

Good idea would be to place cancel sprite on each empty slot and set its opacity to 0 if its not in collision with Words and Words are not being dragged

Where set its opacity to 255 when Words are in collision with them and Words are not being dragged

This way cancel sprite will only show if slot is occupied by Words but not if its empty

Where the same time clicking cancel sprite will move Words back to its original position

It isnt working! Here’s my eventsheet:

Add here WordBank is in collision with cancelinput

That doesn’t work. And I don’t see how it should! When the cancelInput button is clicked, the WordBank group object goes back to its original position before the dragging action. So, a collision with the WordBank group object seems irrelevant to me!

It does work but not the way i want it to. I am trying to access the X and Y positions of the member objects of the group WordBank separately without hardcoding them but till now have been successful in accessing the overall WordBank’s X and Y positions.

Did you just start arguing over something you don’t understand?
I really want to know very straight and clear answer to that question

And what is not relevant to you does not mean its irrelevant to engine

You want to click Red object to do something to Blue object
But if you have few of Blue objects there then to which Blue object?
You need to specify which
So in your case you wanna do something to Blue object that is in collision with Red object
That is how you target Blue object when you specify to do something is done to Red object

Hard codding would be when you write all coordinates manually
While this is dynamically saving position of each object which you could repeat for each individual object at any moment

You know what i actually don’t need any answer from you
I told you what to do and i just realized you intentionally ignored it because you felt its not important
So if you know what to do i gonna leave you alone so you can fix your issue on your own

I wish you good luck

@ZeroX4 Hey, bro

no offense was meant! I was just wondering, perhaps unwantedly so, aloud! You might solve this particular problem i am stuck on, but that doesnt mean i will be able to fathom out the logic behind it, and learning grows through understanding. Its my inadequacy. No offense, bro!

You did not offend me
I simply have bad experience with ppl who do not do what they were told to do

I do not care if you question is it needed or not
I only care if you are doing it or not
And as you seen from my previous message i have no problem in explaining stuff

But i simply don’t see myself helping ppl who don’t know how to do something and when they are told how to do something they choose to do what they want

I am not only one who can help you
There are others who can
I simply am not suited to help you if that is your approach

You need a way to connect the Cancel object with the Word object so that they can be picked together. Think of object picking as filtering. Each event starts with everything “picked”. If there are no conditions, the actions will work on all relevant objects.

Your event is like this:

cursor is on cancelInput     |
mouse released               |          change position of WordBank

The conditions here are saying, pick all “cancelInput” objects that are under the cursor. Or to put another way, filter out all cancelInput that don’t fit the condition (under the cursor).

All other object types, such as WordBank, have not been subject to any filtering. So the action to change position works on ALL wordBank in the scene.

You need a condition (or action) that also picks the specific wordBank needed:

cursor is on cancelInput                           |
mouse released                                     | change position of wordBank
take into account "WordBank" linked to cancelInput |

You would also need to add link cancelInput to WordBank action to the event where cancelInput is created.

Using collision is also a way to accomplish this, but not as robust because you could potentially include other objects by accident (for example if you were dragging a word at the same time).

Well, I tried things my way and I did successfully implement the feature with help from ZeroX4:


But the problem that now emerges is substracting the text value of tempAnswer from inputAnswer which i havent been able to implement. And even if we do implement that the issue of adding text inside of a greater string value when the kid reorders the word blocks will remain.

So, should i instead adopt the approach of logging and evaluating the student values only when the Line1Submit button is clicked. How do i do that? Any ideas?