How do I families and contaners

0 favourites
  • 9 posts
  • Hey. I know a lot of people ask for this. I'm not asking for it to be feature as I know Ash said it would be complex and impact performance. I just want to know what to do.

    When I started my project I had one sprite for the player. I added a new sprite to it's container that I use for it's hitbox. When it is created I pined it to the player. and it worked fine. But then I changed the player sprite to a family because I would want to use different sprites for the player at different times, but would not want to copy the code. But now the hitbox object won't pin.

    Ideas?

    Thanks.

  • This is strange.

    Your having that object in a family doesn't really affect pinning behavior.

    If the hitbox code says for example

    OnStartOfLayout>HitBox>PinToObject>Sprite

    This will keep it pinned to that particular sprite.

    Might be best to link your .capx file here.Might be some minor thing you overlooked.

    -cheerios

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • the player will use the same sprites as NPCs. So I make the NPC family do it's own thing, except for the one that the player will control. one at random will become the player object though variables that state such to the game.

    I have one of each on the layout and destroy them at the start, then spawn them in a "repeat nth times" event. then when the hitbox (being in the same container as each sprite) is created I pin it in it's creation event.

    Due to my project using plugin's covered under ULAs, I can't share the Capax. But I hope this photo showing the "at start of layout" event will show whats needed.

    https://www.dropbox.com/s/zzzefbehffmu8kc/construct.png?dl=0

  • why are you setting the attack box to humans.x,humans.y?

    As far as I understand the attack box isn't in a container with the family, but with the sprite..

    Would setting it's position to sprite.x,sprite.y and pinning it to the sprite work?

  • mmm. that worked. Guess I will just have to know what sprite it's referencing. and use separate events for the pinning. Thanks.

  • if it's in a container, it will automatically go to the sprite in the same container, right?

  • what happens when you have multiple sprites in the family??and the hitbox is pinned to the family object??

    When I tried it just stayed with one sprite.The first on the family list.

  • If I understand the question correctly, there are many ways to do that..

    For example, something like this should work:

    give the hitbox a variable ready (original value 0)

    for each family

    pick by comparison - hitbox.ready = 0

    hitbox set position to family.x,family.y

    hitbox set value ready = 1

    hitbox pin to family

    or if you have to create the hitboxes, you don't even need the variable

    for each family

    create hitbox at x=family.x y = family.y

    -- hitbox pin to family

  • LittleStain

    oh that second one is a good idea. I might try that. thanks!

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