How do I get two objects to stay together?

Get help using Construct 2

Post » Wed Apr 06, 2016 12:31 am

Alright I'm going to try to explain this the best way I can. I'm trying to place two images together, (a right ledge and a left ledge from a tiles for a tilemap). I set them up as one sprite. The left edge as frame one and the right edge as frame 2. I set the speed to 0 so no real animation plays. Both ledges are supposed to come together to make one moving platform. I set the code up for them both to move correctly, but how do I "pin" them together to move as one object? At the moment they move in opposite directions. I tried using the pin behavior with some code but It did not work?
B
11
S
3
G
2
Posts: 11
Reputation: 1,711

Post » Wed Apr 06, 2016 2:23 am

For pin behavior, try using debug to confirm you are pinning to the correct object instance, picking instances can sometimes get tricky when referring to the same object.

Once you have pinned one to the other, you no longer use actions to move the pinned object. When you move the object it is pinned to, both will move.

In this situation though, you probably don't need the pin behavior at all. As both edges of your platform are the same object with different animation frames, an action that makes that object move should move both/all instances of that object at the same time. Just make sure the ones you want to move are picked correctly with conditions.
Mistakes were made.
B
52
S
26
G
110
Posts: 1,620
Reputation: 62,161

Post » Wed Apr 06, 2016 2:42 am

I would have a 3rd invisible object with deactivated collisions, and then activate it when they come together. You pin the other 2 to this one and forget about them
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Wed Apr 06, 2016 3:59 am

How do you use debug?
B
11
S
3
G
2
Posts: 11
Reputation: 1,711


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests