Moving 2+ objects at once

I just started using GDevelop yesterday and I think I was able to do things on my own, but I got stuck with this one. I want the player to be able to push around pillars. These pillars span 3 tiles high and are made of 3 separate images.

I have an object group named Pillars, consisting of the parts of the pillar. I put in a force to the pillar whenever the player collides with it, but they get pushed separately instead of being pushed as a whole.


the reason is, that your player is not in collusion with all pillarparts.
you can work with links and link 2 pillar parts to the bottom pillar part.
or you can work with variables. give the 3 parts a variable (id for example) with the same value.
then check collision only to the bottom pillar part.
and move all parts that are ether linked or have the same id.

something like this:

Edit:
i noticed that you dont need to link them, when you have them in groups already.
just check the collision with only the bottom part and add the force to the group should work fine.

Thanks for the reply. I’ve tried both variable and grouping and I still have a problem, though a different one this time, two actually.

First one is, the other pillars move too. Checking for collision on the bottom part and moving the group works (same one with the variable), but the other pillars also move when I push one pillar. Interestingly, the pillar I’m pushing moves in one piece, but the other pillars leave the bottom part behind. Maybe because the other pillar bottoms aren’t exactly colliding with the player?

Second one is, the pillars doesn’t seem to follow the direction of the player’s push. I was pushing upwards, but they move to the right.

I was pushing the second pillar upwards, and that happened.

thats why you need to give each stack of pillars a uniqe id, so only the pillar group with the proper id is pushed.
secondly, look what i have written in my screenshot for forces (i was aware ure gonna need it ;D )

I’m still stuck.

Can you elaborate more on this one? Do I give each stack a different variable, like say, pillarA_id for the first pillar, pillarB_id for the second one, etc? I’ve tried it and it still moves the other pillars.

^ Here’s what I tried.


^ I was trying for the unique ids here. My first pillar has pillarA_id, but pushing other pillars still moves the first pillar.

You’re talking about Player.TopDownMovement::Angle(), right? I just got it working, thanks! I removed TopDownMovement because I wanted to use WASD keys, turns out I left the “Default Control” box checked for too long. I added it back in and the pillars move according to the player direction now.

Each group of pillars need the same id - but the id of a pillar group needs to be different to all the other pillar groups.

So for example, if pillar_1 has an id of 1, pillar_2 and pillar_3 that belong to that pillar_1 also need an id of 1. Those are the only pillar parts that should have an id of 1.

Each pillar_1 needs an id that is different to all the other pillar_1 ids. To illustrate using your screenshot:

1 Like

Nice, I got it working now.

Thank y’all very much. :smiley:

1 Like