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

Get help using Construct 2

Post » Mon Sep 01, 2014 6:39 am

Prominent wrote:
codah wrote:
I can see issues with this. How would you know if you were inadvertently accessing a behaviour that didn't exist?


Like I said, it would simply ignore it. Nothing would happen if it doesn't exist. You should know how your program works, so running into this issue wouldn't be an issue if you're aware of what things should be doing.
.


That's why I said inadvertently. That would be a very frustrating class of bug.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Sep 01, 2014 8:00 am

@codah

No, 'nickname' plugin could not solve this problem.
B
110
S
28
G
280
Posts: 4,488
Reputation: 156,568

Post » Mon Sep 01, 2014 8:24 am

codah wrote:That's why I said inadvertently. That would be a very frustrating class of bug.

Perhaps, but there's always going to be possibilities for human error with everything.
One way to help confusion is to highlight the event with a color where behaviors may not be active. So it would check all objects in a family and if you reference a behavior that isn't attached to all members, it would get highlighted red as a warning that the event may not fire,etc..
So a kind of, use at your own risk, sort of thing.
B
48
S
23
G
66
Posts: 1,144
Reputation: 39,059

Post » Mon Sep 01, 2014 8:51 am

rexrainbow wrote:@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' ;) )
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Sep 01, 2014 9:36 am

codah wrote:
rexrainbow wrote:@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 :)
B
24
S
9
G
7
Posts: 756
Reputation: 7,312

Post » Mon Sep 01, 2014 11:21 am

vee41 wrote:
codah wrote:
rexrainbow wrote:@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.

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.

viewtopic.php?f=146&t=81429&p=662448&hilit=families+within+families#p662448

Anyway long story short.. I found a couple of people suggesting a reasonable workaround, like this:
There's a nice little trick
Code: Select all
+ Foreach Family1:
   + SmallShip pick by UID Family.UID
      -> Fire Small bullet
   + LargeShip pick by UID Family.UID
      -> Fire Large bullet


What I like to call C2's object type casting :D
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Sep 01, 2014 6:40 pm

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.
B
48
S
23
G
66
Posts: 1,144
Reputation: 39,059

Previous

Return to How do I....?

Who is online

Users browsing this forum: dop2000, LogoGuy2017, OddConfection and 21 guests