Snap-together building blocks [Solved]

Get help using Construct 2

Post » Fri Jun 23, 2017 9:10 am

Hi, I'm trying to make objects snap together at predetermined points.

It is for a space exploration game that involves the construction of modular space stations. The modules are different shapes and sizes depending on what they are for, and have varied numbers of “Connection Ports” depending on their configuration.

The problem that I am having is that I can not figure out how to get the modules to snap together. I've read up on quite a few relevant topics and tried everything I can think of, but nothing seems to be working.

I've been experimenting the most with image points on Connection Ports which spawn connector sprites that are then pinned to the Module.
I think a lot of the problems I am running into are a result of the fact that I don't know how to tell the game engine which connector sprites belong to which modules. In one of my attempts, the modules were violently shaking because they were trying to connect with themselves.
Last edited by Ajbael on Fri Jun 23, 2017 12:15 pm, edited 1 time in total.
B
11
S
4
G
4
Posts: 28
Reputation: 2,831

Post » Fri Jun 23, 2017 12:05 pm

@Ajbael

Would this work for you?:

https://www.dropbox.com/s/j4e79xecspr6d ... .capx?dl=0

Can't take all the credit for this, @justifun pointed me in the right direction in this thread:

viewtopic.php?f=147&t=86613&p=824059&hilit=snap+to+imagepoint#p824059

Also I get the feeling that my solution could be simplified, but this was the only way I could think of to get around situations where you are adding a module in between two or more modules.

You can increase the size of the links to increase the snap range.
B
20
S
8
G
3
Posts: 457
Reputation: 4,053

Post » Fri Jun 23, 2017 12:15 pm

mekonbekon wrote:@Ajbael

Would this work for you?:

https://www.dropbox.com/s/j4e79xecspr6d ... .capx?dl=0

Can't take all the credit for this, @justifun pointed me in the right direction in this thread:

viewtopic.php?f=147&t=86613&p=824059&hilit=snap+to+imagepoint#p824059

Also I get the feeling that my solution could be simplified, but this was the only way I could think of to get around situations where you are adding a module in between two or more modules.

You can increase the size of the links to increase the snap range.


Thanks, this is perfect! I actually read that post by @justifun, but I wasn't able to understand what he meant. There's a lot in the capx that I don't understand, but hopefully I'll gain some knowledge of how these things work when I integrate it into the project I am working on.
B
11
S
4
G
4
Posts: 28
Reputation: 2,831

Post » Fri Jun 23, 2017 1:02 pm

@Ajbael You're welcome :)

If you re-download the capx from the above link I've added in some comments to help explain what's going on, included an extra action in the last event to ensure the link positions remain correct and added a bonus feature: right click to rotate a piece 90 degrees.
B
20
S
8
G
3
Posts: 457
Reputation: 4,053

Post » Fri Jun 23, 2017 2:39 pm

mekonbekon wrote:@Ajbael You're welcome :)

If you re-download the capx from the above link I've added in some comments to help explain what's going on, included an extra action in the last event to ensure the link positions remain correct and added a bonus feature: right click to rotate a piece 90 degrees.


Oh, brilliant! This definitely helps me understand what is happening.
B
11
S
4
G
4
Posts: 28
Reputation: 2,831


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Lancifer, richcoz81 and 27 guests