Pin to multiple instances of same sprite

Get help using Construct 2

Post » Sun Sep 02, 2012 8:48 pm

Hi guys

I'm having a problem similar to this thread, which it seems was never fully solved.

I have an sprite called "Enemy_A", and the enemy has a weapon pinned to him. "Enemy_A" is part of the family "Enemy". When I try to pin the weapon to the family though, it does not pin it to each instance of "Enemy", only the first one it finds.

I made a demo of this problem based on the example that ships with C2: Download

It makes sense in a way - Even if I didn't use a object family and just said "Pin to Enemy_A" in my events, I'd still need to manually set it to each instance of "Enemy_A".

Also, the technique R0J0hound suggested in the related thread doesn't really work with pinned objects because the interface only lets you specify a single type of object, not manually call a object like a text string.

Any ideas on how to fix this? If I have one sprite with a pinned object which exists in the layout several times, how can I get a pinned object to pin to each instance of the sprite?boolean2012-09-02 20:49:40
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Sun Sep 02, 2012 9:23 pm

You could do it like this:

B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Mon Sep 03, 2012 6:46 am

That's very odd...that works. I actually tried the same code earlier today but instead of "Is Overlapping" I used "Choose nearest", which does not work. It's strange because I would have assumed that both would have the same affect.

How weird

But, using the event you suggested seems to work perfectly. I can't figure out though why "Overlapping" would work but "Nearest" would not though.
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Mon Sep 03, 2012 3:56 pm

It should work if you replace "Cogs: Is overlapping" with "Shield: Pick nearest to (Cogs.X, Cogs.Y)".
B
27
S
8
G
8
Posts: 903
Reputation: 8,452


Return to How do I....?

Who is online

Users browsing this forum: theosciandra and 26 guests