Instance picking in a Family is random

0 favourites
  • 4 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • 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 <img src="smileys/smiley5.gif" border="0" align="middle" />

    I wanted the Collisionboxes + Image Box of my Deer to be together. I probably should have used containers over grouping together in a family.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

  • 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?

    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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)