Pick all FamilyA that belong to FamilyB? *Solved*

Get help using Construct 2

Post » Fri Jul 05, 2013 8:13 pm

C2 doesn't do sub-families (yet), so I'm using an approach where I assign the effective parent family to every effective child family.

If I'm working with an instance of the ChildFamily, how can I pick it as the ParentFamily? For example, I'd like to do the equivalent of this:
[code]ChildFamily collides with Bouncer:
+ Pick ChildFamily as ParentFamily:
     -> Set ParentFamily.VelocityX to -50
[/code]EDIT: SOLVED
I think I found a solution and I'd like to share it here for reference. Whenever you'd like to pick as another family within a condition, run a ForEach loop for the ChildFamily. As a sub-event in the loop, Pick the ParentFamily by the UID that matches the ChildFamily. Since UID is a completely unique identifier for the object, this will work perfectly. Here's the above example working with my solution:
[code]ChildFamily collides with Bouncer:
+ For each ChildFamily
+ ParentFamily: Pick Instance with UID ChildFamily.UID
    -> Set ParentFamily.VelocityX to -50
[/code]
I hope that in the future C2 will natively support sub-families. It will make C2 that much more awesome.Dalal2013-07-05 20:30:02
Image
B
10
S
3
G
2
Posts: 196
Reputation: 2,053

Post » Fri Jul 05, 2013 9:37 pm

You could also call a function with the ChildFamily.UID that collided, and in this function pick the parent by UID using the UID you put in param.

In this case, it's the same (as you would need a for each anyway to call the function on all children that collided) but in general it could be better, for example if you have multiple sources of velocity lost in your game. You would then just have to call the same function.
B
17
S
8
G
4
Posts: 473
Reputation: 6,211

Post » Fri Jul 05, 2013 10:43 pm

Ah, good idea. I will probably use a function in my case because I'm going to have a lot going on. Thanks!
Image
B
10
S
3
G
2
Posts: 196
Reputation: 2,053


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], Kyatric and 52 guests