Get Object on Collision [SOLVED]

Yep. It works now. Thanks for the great attention!

Since the events are for both clients, I wouldn’t put any client checks in there, so it works on both machines.

1 Like

One thing is that each client has different variables, but you’re saying that I should put them free in the code (Not under any extra condition)?

Edit: I can’t get it working for the other client, like in chess. Also when I tried to do it for both of the players after a few moves, the pieces on both screens go from the last position to the new one, however when they are moved they stop. I just found out that this only happends when I move one from one screen, and then the one from the other screen. Any thoughts?

I’ll send an image of the code:

for clients and

for master.

Both those snippets are very, very similar. Again, I would look at removing the IsClient check from where it is, and only use as a sub event of the Event "..." received from other client event, to determine the star move.

If I remember correctly, you have the up one way on the master, and up-side-down on the client? If so, you can’t just move the star to the position sent by the other client. You’ll need to work out where on this client’s board that move corresponds to.

I think I know what you mean by this. I have little dots on each cell of the grid and those objects are in a group called Ps. Now, when Star moves, see which Ps it collided with and that name send it to the other client in a variable. If the client receives the event, set Star’s position to the variable.

Then, IfClient = True, set the dots position to… Well, I’ll have to do that part manually, but they’ll be mirrored.

The problem is that the IsClient checks have more stuff underneath them. Because as it is chess, the client and the master both have the white set and black set, events for “eating” pieces, and more. But I guess you mean removing the Star events from the checks. I’ll try that.

Ok. Did it, but still same bug of going into the new position and then rapidly jumping to the old one. I tried data loss mode but didn’t work. It’s even buggier than last time, with the checks and all! (I have a set of whites and a set of blacks and a board on each screen) When It was black’s turn (I move black for now), the Star that I already moved started vibrating, like threating to move to it’s last position, kind of like vibrating. Wierd. Code:

(You can see the IsClient = false down in the image, so you know that the four events are “free” in the code.

Edit: I’d recommend you see all the posts made for a more clear vision of the game, setup and situation.

I searched and experimented and I have no solution fro this problem. I was wondering of you could advise me on what to do next.

Is this post closed?

No, it’s not closed. I’ve been busy the last day, but I’ll help again soon - I’m trying to get a game into the GDevelop game jam (a tight schedule given I didn’t find out about the jam until a couple of days ago).

Oh, sure! Sorry if I was rude, you could’ve just told me! And please tell me when you’ll be able to help me again. Anyways, good luck on your project!

Not at all, I should have communicated earlier.

Hi! I thought it ended here, but I ran recently into a problem. I was happy with the P2P events, then tragedy struck. As I was mirroring the Ps, so the position is shared between the two players (Star to left for master, Star to right for client), I realised it didn’t work. I mirrored them again, but no luck. I made another event, IfClient was True; mirror actions, if it’s False; set the pieces to their orginal position. Then I saw that the variables used the Ps.X (Or Y), so it was going to coordinates instead of the object. I wonder if there’s a way to:
a) Use the code that I have and modify it to work like this.
b) Write another or more events.

Basically, I need the variable to return the name of the Ps. Or, an action like (Set Star’s position to object…)

Thanks in advance,

Use option A, but instead of passing screen co-ordinates, pass the co-ordinates relative to the centre of the board. So something like this pseudo code : board.CenterX() - Star.X(). The receiving event then takes off the value from the centre - board.CenterX() - ValuePassedX. You’ll need to work out the centre of the board.

Hi! I don’t know what to change in my events with that explanation (If the Star on your example would be “Ps” in my case, or Star and discard the Ps’ events). I was hoping you could tell me what’s what and who’s who, what object I have to replace with which, and what condition/action I have to change.

(Ps is a group of objects, 77 to be exact, that are in each cell. So if an object lands there, get its name and put it in a variable, send it to all clients, and set their piece’s position that collided to that Ps)

Edit: Images require explanations, will be under this post.

Best regards,


This is the P2P code I’m using, the one I think will change more with these suggestions. Uses the Star as a default example, yet there are many pieces. Ps is the group of the grey dots, 77, will see them in the image below. Not need to explain much here, this code is repeated throught this “How do I…” post.


Okay, here you can see the game. As you can see, its like chess, just a re-make. The streched stars on the sides are invisible on-game and detect other gray dots (when you click a piece, the other gray dots appear, indicating where you can go, and you can’t go off the board, so they are deleted). There are two sets of pieces, black and white (groups), Star is in the middle of the board. As you can see, the cells are hexagons (Hex grid extension) and the grey dots are in each cell, waiting for a piece to land there to activate a signal, like a button.

I thought it would be much easier to show the game, the setting and position of each piece, to have a better understanding of the situation. Hope it helps.

Last but not least, the re-locate group of events (mostly actions). It’s not full (that would take 3 images minimum), but you can see I set them to thought positions. However, these positions are the opposite, “mirrored” that each piece is currently in. P77 (Actually named “P76”) goes to P (P1), P2 to P75 and so on…

The event below is the same, but with the original positions;

but as you can read, it didn’t work.

Anyways, hope this large post helps you to help me, I gave you as much information as possible, which was not easy by my writting skills. Hope this board and pieces position, P2P events and re-location images help you better understand the settings of my game.

Again, sorry if I don’t sound coherent, English isn’t my native language.

Thanks in advance,


Basically, I want to be able to set an object position to an object, without using X and Y. If that’s not possible, the images and explanation will help to find another solution, but that’s pretty much it. So the Star, for example, collides with P55, put that name in a variable, send it to the other client (all clients event), then their Star’s position will be set to that variable, that contains the name of the object. I already know how to get the name of the object.

The problem is you can’t find an object by entering its name as a string.

Also you’ve created 76 instances of the grey dot. That’s not very efficient You’d be much better off using one object with an id, and then passing the id. This is easy enough to set up - the board follows a pattern, which means it can be coded using a couple of loops.

I’ll see about creating an example project for you to work with. In the meantime, can you confirm that p1 for client 1 is approximately at (324, 303), and p1 for client 2 is approximately at (1204, 1145)?

I just couldn’t get it working any other way and it was taking to much time



Yes, yes it is. And it uses a hexagonal grid, of 146.16 width, and 119.77 height.