Snap-together building blocks [Solved]

0 favourites
  • 5 posts
From the Asset Store
Place blocks on a board, join them together to form even bigger blocks!
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)