Instance picking in a Family is random

Get help using Construct 2

Post » Fri Apr 19, 2013 5:24 am

https://www.dropbox.com/s/sblfm2znnm4x7hz/Working%20File4.capx

Sorry it's a mess, but take a look at the DeerAi eventsheet, and also the part after the comment 'Spear collide behaviours'.

Basically, I just added in the last part to DeerAi, which is what to do if the Deer family has the state "dead".

Before that, everything worked properly, with the individual instances of the Deer family moving indepedently.

However, now I want to have that, when the spear collides with either DmgHead or DmgBody (both are part of the Deer family), then the nearest entire 'Deer' instance would be set to "dead". With the state of "dead", then the Deer instance would stop moving and stop animating (for now because I don't have the 'death' animation ready).

I don't know why this isn't working. In the main event sheet, it works with setting the collision boxes (DmgHead and DmgBody) every frame to follow the image points of each individual Deer instance.

I think for reason, the Spear is setting the variable ('state') of all instances of the Deer family, but I have no idea why. I tried using Pick Nearest to the spear on collision, but that doesn't work either.

Edit: I'm starting to think I confused a Container with Families

I wanted the Collisionboxes + Image Box of my Deer to be together. I probably should have used containers over grouping together in a family.Byakko2013-04-19 07:03:02
Create HTML5 games
B
10
S
1
Posts: 27
Reputation: 697

Post » Fri Apr 19, 2013 7:17 am

You are not picking any instance of deer family, 'on collision' event picks your hit box, but as no specific instance of deer family is picked, they are all affected.

I'd do this:

Get rid of deer family, put all deer animations in to single deer object.
Place hit boxes in container with the deer.

Then it should work, as deer would be automatically picked with the hit box, due them being in same container.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Fri Apr 19, 2013 7:43 am

Right, I forgot about the existence of containers at all, so I started using 'families' instead because I wanted pseudo-container behaviours.

When I put all the parts of the Deer container together, would I still have to do the On Start Layout event where I spawn and pin all the associated collision boxes?

Or after making the Deer-container, I just ctrl+drag to duplicate it throughout the layout and it'll be exactly the same?
Create HTML5 games
B
10
S
1
Posts: 27
Reputation: 697

Post » Fri Apr 19, 2013 7:56 am

[QUOTE=Byakko] Right, I forgot about the existence of containers at all, so I started using 'families' instead because I wanted pseudo-container behaviours.

When I put all the parts of the Deer container together, would I still have to do the On Start Layout event where I spawn and pin all the associated collision boxes?

Or after making the Deer-container, I just ctrl+drag to duplicate it throughout the layout and it'll be exactly the same?[/QUOTE]

You don't even need to spawn the hit boxes, that is done automagically due them being in same container. You only need to do the pinning, which I'd move into 'on deer created' event.

To summarize:

Only place instances of deer object in the layout, no hitboxes.
On deer created event, place hitboxes (to imagepoints of deer object) and pin them.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests