Issues with pinning overlapping family objects in loop

Get help using Construct 2

Post » Sun May 01, 2016 5:39 pm

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.

Image

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.

Image

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
B
4
Posts: 10
Reputation: 220

Post » Mon May 02, 2016 6:16 am

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 got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Mon May 02, 2016 1:56 pm

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.
B
6
S
2
Posts: 28
Reputation: 508

Post » Mon May 02, 2016 2:59 pm

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
B
4
Posts: 10
Reputation: 220

Post » Mon May 02, 2016 5:54 pm

@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.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue May 03, 2016 6:08 am

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
ImageImageImage
B
71
S
22
G
259
Posts: 3,794
Reputation: 143,704


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests