Pin one sprite to another of the same type

0 favourites
From the Asset Store
Wall Pin Board is a hyper causal game developed for fun and inspired by YouTube video whose link is given in description
  • Sorry to dredge this up again, but i'm facing a similar issue and no answer is yet to be found.

    I did come up with a rather convoluted workaround that involves spawning invisible anchors to pin to so you are pinning to a different sprite type, but if there is a more elegant way to do this I would love to hear!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Only way I know how to do this is to have an intermediate object.

    That would be the tail in this simple example:

    Tail -> Pin to Cat

    Cat -> Pin to Tail

  • You're absolutely right, this thing has hindered me from efficiently designing a button that builds a bridge when activated, the bridge is made out of smaller blocks. I can't spawn multiple instances of the same object, (I was planning to use "set visible" on the bridge(n).. But it's impossible to reference an object by its index, I think)

  • How do I pin a object to a cloned object? Meaning using the UID number of the cloned object?

  • Hi, I have the same trouble. Maybe someone can help or give us a tip.

    I have an enemy with Sprite-Head / Sprite-Body / Sprite-ArmLeft / Sprite-ArmRight so if I pin them together everything is fine.

    But when I want to clone the enemy (with all his sprites) the pin object pins to the wrong enemy.

    Pick by UID is an option, I know. But my enemies will be spawning every X secund(s). So i don't know which UID they'll have (or maybe I do?)

    I also tried "pick sprite by overlapping object":

    Sprite-Head overlapping Sprite Body

    -> Sprite-Head pin to Sprite Body

    Sprite-Arm overlapping Sprite Body

    -> Sprite-Arm pin to Sprite Body

    I know it's a very messy way. And I also tried the same methode with the condition pick by nearest....

    But both results are not working properly. Maybe "pick sprite on collusion" works better, but still, it's not a nice way to make it work.

    Hopefully somebody can help us here. Thanks!

  • Mario I don't know how you could solve this, but bear in mind that multiple pinned objects might start lagging. Especially it they are pinned in a [Parent<--Child<--Child of child] fashion. It seems to me that manual positioning is always faster and I'd like to hear the more advanced users' opinions about this.

  • immortalx thank you for your advise, you are right. As I said, it's a very nasty way of "coding" and in the end it's not solving the problem.

    I guess, I have to read more about IID, UID and Functions.

  • Hey Mario4President,

    If each enemy is made up of a set of unique object types, then you might be able to use the "Containers" feature of Construct 2, to associate all the objects of an enemy.

    This will work as long as an enemy only needs one of each object type.

    For instance, if an enemy has a body and two arms, all as separate objects, then you'd need the arms to each be unique objects (e.g. leftArmObj, rightArmObj), as you can't put the same object (e.g. armObj) in a Container twice. At least not to my knowledge.

    Containers page of Scirra's C2 Manual

  • fisholith

    Hey, I was playing around with Containers too. It'll work.....but not for me, because I need the sprites to be independent. So if you hit the Sprite_Arm, only the Sprite_Arm will be destroyed. Not the whole Enemy. Containers are fine, but not in this case.

    Anyways, I found a very good tutorial written by TELLES0808. It helped me a lot, I played around a bit and I think I found a workaround for my problem.

    In case somebody is interessted in, I'll try to post it here. Right now I'm overworked but hopefully I'll find some time in the evening.

    I would like to post the link to the tutorial but I'm not allowed to, since I have not enough rep-points for posting urls but the tutorial is called "Understanding UID, IID, Health, Cards and Rocket smoke trail."

  • Ah, yeah, containers will take everything down with them if they get destroyed.

    Below are a few possible alternatives that might work in place of containers.

    Also, I posted the link to the tutorial you mentioned at the very end.

    UIDs & Private Variables

    As an alternative to containers, you can store the UID of the ArmObj in a private variable of the ArmDetectorObj.

    Then if ArmDetectorObj collides with lava, you can,

    Pick ArmObj by UID, (using the UID you stored earlier), and Destroy just the ArmObj.

    To make sure the UID gets stored correctly, you can Have the ArmObj's "On created" event be responsible for creating the ArmDetectorObj, and saving the ArmObj's UID into a private variable of ArmDetectorObj.

    Thus, whenever you create an ArmObj, it will automatically instantly create and link its very own unique ArmDetectorObj .

    Pin Behavior & "PinnedUID" Expression

    In some cases, if you are already using the Pin Behavior, you can use it's built in PinnedUID expression to get the UID of the pinned object, though this is more of a special case.

    Manual page: Pin Behavior

    Store Reference Behavior

    Another option that might be worth looking into is the third-party "Store Reference" behavior.

    It can be added to objects to make linking them in events simpler and easier to read.

    Forum page & Download: Store Reference Behavior

    • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    Here's the link to the tutorial you mentioned

    Understanding UID, IID, Health, Cards and Rocket smoke trail.

  • fisholith

    Ah, yeah Version 1 "UID & Privat Variable" is a nice solution too. In fakt, it's even better, because the Programm-Code will be much smaller and clearer than the way I did it.

    and thanks a lot for posting the third-party Behavior. It's great! It will help me with much more than only in this matter!

  • is there someone here can help me with my custom analog control for my character?

  • Has anyone answered the original question here yet?

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