Hi, you did not mention what actually happens, but one problem in your events is that you have a ‘repeat for each’- condition and a ‘trigger once’-condition together. You need to delete the ‘trigger once’-condition to make your repeat-condition run properly.
Another way to attach two objects is to use the ‘sticker’-extension.
Thanks for the response. So what actually happens in this situation is one instance of ToAnchor will be created on the top left most AnchorPoint, which will follow the square it’s assigned to.
Okay, so what happens if trigger once is in a repeat for each? I disabled the bottom two actions and it does generate one ToAnchor for each AnchorPoint. It doesn’t seem to ignore the trigger once either.
Thanks for letting me know about the sticker extension, I’ll check it out immediately. I would still like to do this with links though, for educational purposes.
I think you’re right. Let me look into it. Maybe someone else is more familiar with linking.
Edit: I think I understand now. The linking order doesn’t matter. It’s 2 way. It’s the “take into account all”. It’s only changing the “picked” status of the first object. If you check “red” linked to “green” then it "picks the red that are linked but ignores the green. So, all instances of green are left the same if there wasn’t a condition.
I’m a visual learner. I threw this together. The 1st green and red are linked. I drew a line just for reference.
If you check green linked to red then it picks the 1 green but ignores and leaves red picked.
If you check red linked to green then it picks the 1 red but ignores and leaves green picked.
It only changes the picked status of the first object. So, any object that you want to use in an action should match that first object.
In testing this seems quite plausible. That would make quite a lot of sense if so, in my example the action refers to both the ToAnchor and the Anchor Point, seeing as there are multiple instances of both, it seems the conditions are unable to pick both parts of the specific pairing. It works if I I have the ‘take into account all link’ in a ‘for each’ instance event type. but I’m trying to avoid that, as it is resource intensive.
Have the Y coordinate of ToAnchor be set by the Y coordinate of AnchorPoint, for each individual pair individually, so essentially they follow each other. The point though is not just Y co-ordinate but to have any information be passed between the two.
It depends, if you read this thread the main reason that the events did not work as intended was the order [Solved] Link multiple objects
I guess it really depends on the objects and how many other ‘repeat’-conditions you have. I would just go with it and start to worry if it really causes performance problems.
Thanks, okay so in the example in ‘Link multiple objects’ they also had to use a for each, I see, I see. I have noticed that changing the order works. Very curious to know why though. No major issue, but knowledge is power. Unfortunately I have noticed some performance drop because I’m hoping to produce hundreds of the instance in question. (Not in my test, but the project I’m working on that I made the test for.) But in this case the sticker should work.
Ah thanks so much for helping me find the answer to the trigger once thing, that makes sense now.
By setting the X and Y ‘position’ of ToAnchor to be equal to the X and Y ‘position’ of AnchorPoint. But the position, is really just an example, what I’m trying to understand is the flow of information between the two, which I think we might have found a close enough answer for.
I still wouldn’t mind knowing a bit more about the how and why it works this way, if anyone has insight into it.
But this is enough information for me to work with so thanks muchly.
Edit: I see you are placing and linking. Sorry. I’m done for the night. Good night.
I you’re just placing them then you can skip the link and during the “for each blue” use “create red at the blue X,Y” (or CenterX, CenterY) or use the “put the object around another” action. You can also add the object and link them at the same time.
Yeah so in the game I’m working on I’m spawning units during play and then when they take damage for the first time a health bar is spawned over their heads. It works I’m just trying to make it a bit less intensive.
ok. That info helps. I would use the sticker behavior. It’s not installed. You need to search for it. Add to your project then assign it to the object that’s being stuck. In this case the health bar.
If you’re spawning units, it would be
add unit
add and position health bar
link health bar and unit
stick health bar to unit (the healthbar will stay the same distance as when stuck)
Now, if you’re using projectiles to cause damage, you could use the Collison to “pick” the unit. If more than one unit could be hit then you’ll need a “for each object” but it would only be for the ones that are colliding.
collision unit and projectile
—[sub event] for each unit object
---------[sub event] take into account all healthBars linked to unit | some action here
thanks. Now, I used a mouse, so I knew only one object could be selected. If a projectile can hit more than one unit then the collision will pick all objects. So, under the collision event, you would need a for each unit. The rest of the code would be the same. Also, if more than one projectile could hit the same unit, you would also need a “for each projectile”. The odds might be slim but you need to plan for everything. It hurts my brain at the moment on how you handle multiple hits.
collision unit and projectile
----for each unit
--------- take into account each healthbar linked to unit | add action here or as a sub-event
or
collision unit and projectile
— for each projectile
----------for each unit
-----------------collision unit and projectile
-------------------------- take into account each healthbar linked to unit | add action here or sub-event
For multiple units and multiple projectiles, I believe it would look like this. Now, it looks like a lot of looping but it’s only checking the colliding objects. In my example, you can drag the red and blue dots and it will draw a line between colliding blue and red but not the same colors. (It uses 2 sprites, 2 text objects and a shape object)
Ah I see so the conditions nested in the for each can fire simultaneously, checking each possible combination individually therefore producing different results but importantly allows multiple collisions to be processed simultaneously. And the picking scope of the repeat for each is lowered by the condition they are a sub-condition of, only the instances in the collision are checked. (Is that right?)
I had no idea it worked like this, I’m sure this would have caused me grief down the line.
This is very useful information, much appreciated.
Yes, it took me some time to understand instances and I’m still a little fuzzy. The conditions remove instances until a new event or you use object “pick all instances”