Family Question -- Resolved

0 favourites
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Resolved by

    pick fam.uid that == fam.uid

    the error came from nesting families - and derping >.>

    Ok, I'm confused...

    https://www.dropbox.com/s/ajnyf2yigovr4g7/familyIssue.png?dl=0

    This code affects every single member of the family, as opposed to each individual member of the family that ACTUALLY matches that criteria

    Edit: Maybe i have not been clear in my description....

    Create family - canDamg

    - variables

    -healthCurrent = <varies>

    -healthMax = <varies>

    -damgDealt = 0

    -healTaken = 0

    if canDamg is overlapping damgBox

    trigger once

    - set self.damgDealt = 6

    if canDamg -- damgDealt does NOT equal 0

    --- spawn damgText

    ----set damgText to Visibile

    --- set damgText.Text = damgDealt

    --- set canDamg.healthCurrent = to (canDamg.healthCurrent - canDamg.damgDealt)

    --- set self.damgDealt = 0

    this causes EVERY single object in the family to have damgText spawn and display the amount of damage done

    it should only cause canDamg.mobA the slime beast who just got hit - show 6 damg dealt

  • You are not picking specific family members..

    try using pick by comparison, or ofcourse for each..

  • Containers and families do not work well together, so even if you are using them in that case, all instances of the text object are picked so all will be affected by the actions.

    And if you were not using containers, then this is the expected result.

  • I haven't tried using containers, I'll look that up -- but i am picking specific family members -- all members of the "canDamage" family, who's damgDealt does not = 0

    Edit: containers will not work for what i'm doing

    • this code is designed to make text pop up over an enemy - with varying affects - colors ect - and i'm creating and destroying them so i can animate them in a satisfying way - critical hit - weapon effects - ect
  • Try doing a Pick where damgDealt=0, then a For each canDamg.

  • and adding the family.uid to the textobject as an instance variable so you can get the correct text for each family member (workaround for not being able to use the container)

  • doing a Pick where damgDealt=0, then a For each canDamg. showed me that every other expression i had involving families chose the first object in the family added to the project - that construct 2 can't pick out individual objects in a family that make a statement true - thus defeating the entire purpose of families

    I've never used UID before, but I'll look into it

    thanks for the replies

  • There is no reason it shouldn't behave as intended. Like you said, families were created for situation like these, where multiple object types share a common behavior. Could you post a capx with the issue so we can try to see what's wrong ?

  • I figured this would easily work as intended, and was in the process of creating destroy-able barriers and knockback from enemies inflicting damg to the player

    also character takes a lot of fall damg, because it's currently based on air time as opposed to vertical fall distance

    -------the error I came to the forums is housed in the damgText_Logic Event sheet

  • The problem stems from your usage of multiple families at once. Unless I'm mistaken, picking a particular family member, won't allow you to directly affect its family variables of another family without additionnal picking. I guess you could try to add a "Pick by unique UID" of every other family so only one object is ever selected.

  • On event sheet healthBar, event 10, you are checking for tookDamg, but you aren't picking the single enemy-health objects, so all are showing. You need to maybe use a container to associate those items and use a UID to pick one item that is linked to the enemy.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are some issues, and finding the specific reason is not likely to be one thing.

    The first thing that will cause you issues though are that you do a "for each canDamage" however this family is not the same as genEnemy. So even if you do a for each canDamage and then do genEnemy is overlapping Damgbox. the for each have no effect as these are completely different objects to the program. so it selects all genEnemy objects.

    The way you use for each is a bit wrong or misunderstood. And doesn't really do anything in this case.

    Normally when you need for each is when you need different things to happen to a range of objects. So placing it as the very first condition is not very common as its not really needed in most cases.

    The normal way of using it would be for something like this, if we imagine that a bomb explode in the middle of some enemies.

    First you need to pick all the enemies that are hit (Enemies overlapping explosion) This will select X amount, lets say 5 enemies.

    Each of these enemies we want to fly in random directions. So we add a for each Enemy as the last condition.

    And then in the action, we do:

    Set Enemy.position X = random(300)-150 Y= random(300)-150

    (This is just simplified for the explanation and wouldn't work correctly )

    Which will set each enemy position to a random X,Y within that range.

    So first you isolate the objects you want to work with and then you do something for each of them.

    In your case you might be able to solve it if you after the for each in the top of the event add a "Pick genEnemy.UID = canDamage.UID"

    Since these two families have the same UIDs, however I don't know your program well enough to know if that will fix it completely or not

  • nimos100 pointed the faulty events. Remove both "For each canDamage", and put a "Pick canDamage with UID = genEnemy.UID" under the "Is overlapping". This way, both the genEnemy and canDamage will refer to the same instance.

  • Just another thing that you probably would like to solve. Your enemy_health_bar is going nuts and keeps creating them none stop. Just if you weren't aware.

  • if i use pick by unique uid - wouldn't that still present the issue of being unable to choose the individual object's uid that is being affected? - since i broke the family system and am unable to make code affect individual members -----

    or am i missing something lol

    Edit: had no idea about how it was constantly making health bars - that system is very much infant stages lol

    • you're sure it's not just that it can't tell if the object has taken damg?

    because that health bar is supposed to be invisible until it takes damg for the first time - but im having the same issue where it cant single out objects in a family - in the event sheet - since when one object takes damg - all the health bars appear - though im not sure how it's variable is reacting to that - since it should stay false

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