Pinning objects to multiple creatures

Get help using Construct 2

Post » Thu Feb 07, 2013 9:59 pm

This should be an incredibly simple problem, but I just can't find the solution.
I have multiple enemies, different instances of the same object, split between a head and a body so the head can be destroyed by headshots.
I can't properly attach each instance's head to the body.
My various attempts have either failed completely or just attached every head to the same body.
B
6
S
1
Posts: 67
Reputation: 986

Post » Thu Feb 07, 2013 10:04 pm

If you make the body and head part of a container then you can easily do what you want to do without pinning.

select the body and click "create" in the container section of the properties on the left

then click "add object" and pick the head.

create the enemies by spawning the bodies, and the heads will automatically generate as well

then use something like bullet on collision with head, destroy head.
it will only destroy that particular head.

B
50
S
21
G
8
Posts: 844
Reputation: 10,299

Post » Thu Feb 07, 2013 10:08 pm

[QUOTE=justifun]...
then use something like bullet on collision with head, destroy head.
it will only destroy that particular head.[/QUOTE]


Actually no. Destroying the head will destroy all elements in current container. Instead of destroy You can make it invisible or change animation.
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Fri Feb 08, 2013 1:40 am

There's a step missing in here. Not only is the head not following with the body, but it's automatically generating at the body's origin. Without the head following it, the same problem is still there.grimwolf2013-02-08 01:42:06
B
6
S
1
Posts: 67
Reputation: 986

Post » Fri Feb 08, 2013 1:56 am

Example of containersshinkan2013-02-08 01:56:36
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Fri Feb 08, 2013 1:58 am

I can't open it, you're running the beta release and I'm still on the stable one
B
6
S
1
Posts: 67
Reputation: 986

Post » Fri Feb 08, 2013 2:04 am




Head and body are in container.

In my example on start of layout I destroyed body sprite (head is automatically destroyed) to make sure there are no objects on layout.

When you press left mouse button new object body is created (is in container with head so head sprite will be created as well) then i used the pin behavior on head to pin head sprite to body sprite.
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Fri Feb 08, 2013 2:10 am

Ah, see I have all the enemies pre-placed, not spawned. I assume then that I don't really need a container.
I figured it out, though.
I just used the Event System > For Each > Body, then the Action Pin Head to Body.
I wish I knew exactly how it was able to determine which head to pin to the body, but none the less it works.

Edit: It seems I do need the container. That seems to have been what was doing it; it preferred the head inside it's container when attempting to pin one on.

Thank you for the help, both of you.grimwolf2013-02-08 02:15:09
B
6
S
1
Posts: 67
Reputation: 986

Post » Fri Feb 08, 2013 2:24 am

You do not need container for that - it's only an easy and quick way to do this.

Other way, without using containers would be something like this.


ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170


Return to How do I....?

Who is online

Users browsing this forum: anty21ro, fr0z3n, LeFuji, newt, RookieDev, TRMG and 19 guests