Align a single instance of a sprite to object?

How do I…

I’m trying to align an instance of a game piece to a location on the board. A the moment a player selects their game piece instance (i.e. white circle) and drags it to a location on the board for that specific place (black circle). I am trying to align this single instance of a white circle to the single instance of the black circle.

What is the expected result

Align the white circle to the closest black circle. Next move a new white circle gets aligned to another black circle

What is the actual result

Misaligned or all objects Center on a single black circle

Related screenshots

Screen Shot 2024-04-28 at 9.54.14 pm

Hi! Are your black circles objects or are they part of the background? If both are objects, the black circles and the white circles, you could use their center points to position them.

Can you provide a screen snip of the events that deal with dropping the player piece and positioning it over the black circles?

And also a screen snip of the points for both the player piece and the black circles? If the black circles are part of a background image, then making them a separate object would make things a lot simpler.

thanks for the quick response, Black circles are separate objects (though I created them as tile sprites and not sprites (easy enough to fix)
Screen Shot 2024-04-29 at 7.58.42 am

code - so I understand why it’s grabbing every instance I just don’t know how to grab the single instance

I’d suggest you update the black circle to be sprites.

Set the origin of the black circle and player objects to the centre of their circle image.

Then remove the “Put player around circle...” action, and instead position player at the circle.X() & circle.Y().


BTW, that “Put player around circle...” is better used for one object orbiting another.

thanks everyone, here is the code I used

Nice, thanks for sharing your solution.

One improvement I’d suggest - since player1 is dragged around, use a standard event with Player1 was just dropped and the "Pick the circle2 nearest..." as conditions instead of repeating for each player1.

With the "Repeat for each object" event, the condition and actions are performed every game frame. This isn’t necessary, as the actions only need to be run when the dragging action has finished.

Awesome thanks MrMen! And everyone who took the time to help out