How do I access instance's behavior from within a family?

  • >

    > > codah

    > >

    > > No, 'nickname' plugin could not solve this problem.

    > >

    >

    > You're right, I had a go but it doesn't solve anything. I wonder about families within families (multiple 'inheritance' )

    >

    That has been discussed many times, it is just not what families are meant for

    vee41 Are you referring to the OP or my 'families within families' comment?

    If the latter, you're right there has been a lot of discussion (I've just had a read over some older posts). There is obviously a desire for this kind of thing, and I don't think it's totally without merit. Ashley quite categorically said that this won't be implemented, as you can have objects in multiple families. While this helps with some things, it doesn't cover all needs.

    [quote:1yip5d31]Families already implement inheritance. If you want multiple inheritance, you can add one object to multiple families. That should be equivalent to having families in families, so there's no need to implement that.

    Anyway long story short.. I found a couple of people suggesting a reasonable workaround, like this:

    [quote:1yip5d31]There's a nice little trick

    + Foreach Family1:[/p]
       + SmallShip pick by UID Family.UID[/p]
          -> Fire Small bullet[/p]
       + LargeShip pick by UID Family.UID[/p]
          -> Fire Large bullet[/code:1yip5d31][/p]
    [/p]
    What I like to call C2's object type casting
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The thing is, if you have 50 objects in a family, and say 25 of them use a behavior, it'd be much simpler/cleaner to

    do this:

    +Foreach Family1:

    -> Behavior action.

    or even:

    +Foreach Family1:

    +Instance has behavior (enables access to behavior's actions/conditions in sub-events)

    -> Behavior action.

    + Behavior condition

    ->behavior action.

    ...

    The reason it'd make it better is because if you need to add or remove objects to and from a family, you don't have to create all the extra events to do the same thing.

    Sure, you can put the ones with the same behavior into a family and give the family the behavior, but that would just complicate things and introduce bugs and make writing the events counter-intuitive.

    Try putting physics behavior on an object, and then put that object in a family where the family has a physics behavior and you'll see it get messed up and not work because the behaviors clash with each other.

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