I have manually placed 5 Enemies on the layout. At the start of the layout I want each enemy to spawn a Gun and a Helmet, and have that Gun and Helmet be pinned to the specific Enemy that spawned it. At the moment each Gun and Helmet gets pinned to the first Enemy instance rather than the one that spawned it.
Here's a capx I made showing my problem (and I assume also showing my lack of understanding on C2 basics):
Thanks if anybody can point me in the right direction!
PS: I've had no problems getting sprites to pin to their creation instances during other events, such as "On Mouse Click" spawn Enemy->Enemy spawn gun->Pin Gun to Enemy. But it doesn't seem to work for "On start of Layout". I've tried with other Events (like an overlapping invisible sprite, or Compare Time) but even with "Trigger Once if true" at the end of the event it just constantly spawns new sprites every tick... which is a completely different problem I'm having, and which is why I want to use the "On start of Layout" for the gun/helmet spawning+pinning.
Simply replace "On start of layout" with "For each Enemy"
System --> For each Enemy
Wow that's so simple it hurts. Thanks Danijerry!
Oops, spoke too soon. It keeps creating guns and helmets every tick which kills the frame rate. I tried putting a "Trigger once while true" to no avail (which never seems to work, so perhaps I'm using it wrong". The "For Each" event's description is "The actions will repeat once for each instance of the object", so I'm not sure why it's spawning them continuously.
CAPX - http://dl.dropbox.com/u/5478701/Shadowtest/instancepinninghelp2.capx
Okay I figured it out. Instead of replacing the "On start of Layout" with the "for Each", I made the "for Each" a subevent.
CAPX - http://dl.dropbox.com/u/5478701/Shadowtest/instancepinninghelp3.capx
Oh.. I am getting it, all the events will be run every tick if the conditions are met. That's good to know. Thanks.
How events work.
it's the backbone of C2.
Develop games in your browser. Powerful, performant & highly capable.
Thanks Kyatric, that clear's up a lot.