Pinning to Instance - Simple dumb question

Get help using Construct 2

Post » Thu Mar 22, 2012 2:43 am

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):

http://dl.dropbox.com/u/5478701/Shadowtest/instancepinninghelp.capx

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.Puck2012-03-22 02:44:05
B
32
G
1
Posts: 18
Reputation: 1,663

Post » Thu Mar 22, 2012 3:27 am

Simply replace "On start of layout" with "For each Enemy"

System --> For each Enemy
B
28
S
9
G
6
Posts: 30
Reputation: 6,609

Post » Thu Mar 22, 2012 3:37 am

Wow that's so simple it hurts. Thanks Danijerry!

EDIT:

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

EDIT 2:

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.capxPuck2012-03-22 03:54:57
B
32
G
1
Posts: 18
Reputation: 1,663

Post » Thu Mar 22, 2012 4:08 am

Oh.. I am getting it, all the events will be run every tick if the conditions are met. That's good to know. Thanks.
B
28
S
9
G
6
Posts: 30
Reputation: 6,609

Post » Thu Mar 22, 2012 4:45 am

How events work.
it's the backbone of C2.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Thu Mar 22, 2012 5:39 am

Thanks Kyatric, that clear's up a lot.
B
32
G
1
Posts: 18
Reputation: 1,663


Return to How do I....?

Who is online

Users browsing this forum: Zebbi and 21 guests