Issues with pinning overlapping family objects in loop

  • Hey all,

    Would appreciate any advice anyone has on this problem, been trying to fix it for a few hours now to no avail.

    So, I've got a series of shaded Hexagons, which are all the same object, and are stacked edge to edge in the 2D plane, as shown below.

    After these are spawned, which is done procedurally through data in an Array, I want to Pin each Hexagon to their adjacent Hexagons.

    I have a function to do this, which is shown below.

    This function seems to do sod all however, and I've tried many variants, none of which seem to work. I've created a second family for the Object, so that the "For Each" loop doesn't single out one Hexagon for each overlap check, however other than that i'm out of ideas.

    Does anyone know where I might be going wrong?

    I need the Hexagons to be pinned to their adjacent Hexagons so that when some are destroyed leaving two separated blocks, they now behave as separate collected objects

  • Can you tell us first what are you trying to accomplish? Why do you want to pin a hexagon to another hexagon? What is your big picture? What is this seemingly puzzle game all about?

  • I don't totally follow your method - it seems you're trying to pin a hex to multiple other objects? If that's the case then that won't work as an object can only be pinned to one 'parent' or 'target' at a time. However, a 'target' or 'parent' object can have multiple objects pin themselves to it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi both,

    Thanks for your replies.

    I'm trying to make a space shooter where you can design your own ship in a Hex grid format. The reason for the faff above, is that when pieces of the ships hull are destroyed leaving two intact pieces, I want the piece not connected to the Cockpit to drift away and be destroyed itself.

    I was hoping to achieve this through pinning each Hex to their adjacent Hex's, however as you pointed out Robot, an object can only be pinned to one other object.....

    So to achieve this effect, I guess I'm going to have to go down the rabbit hole a bit... I'm thinking Pathfinding may be a good place to start? I.E:

    Hull created --> Pin to Cockpit

    When Hull is Destroyed

    - For each Hull, Pathfind to Cockpit via Hull pieces.

    - Path not Found --> Unpin Hull --> Destroy animation etc...

    Does this sound like a sensible place to start? My concern with this approach is that with big ships, its going to be a very intensive process. I.E up to 100 pathfinding checks each time a piece of hull is destroyed

  • JayPritchard Here you go sir.

    https://

    drive.google.com/open?id=0B1SSuCVV8v74WFVYWDYwRVZVd3M

    But you may have to pick the nearest, instead of in creation order, to aclompis wat you want.

  • You can use recursion to link the sprites by a number. You can then pick by number to move, or pin them to hidden sprites for the movement.

    http://www.blackhornettechnologies.com/ ... curse.capx

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