0 Favourites

Pin to multiple instances of same sprite

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

  • You could do it like this:

    <img src="https://dl.dropbox.com/u/11087850/PinMultipleObjects.jpg" border="0" />

  • 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 <img src="smileys/smiley5.gif" border="0" align="middle" />

    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.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • It should work if you replace "Cogs: Is overlapping" with "Shield: Pick nearest to (Cogs.X, Cogs.Y)".

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