Containers and Families

Discussion and feedback on Construct 2

Post » Sat Mar 09, 2013 11:28 pm

Containers and Families don't mix reference associated instances.

Lets say you have 2 objects and 2 families

If hitbox overlaps Attack
> destroy movebox

This works as intended with Containers and instancing.

if hitbox.family overlaps attack
> destroy hitbox.family

This works as intended, destroying only that one instance.

if hitbox.family overlaps attack
> destroy movebox.family

This destroys every movebox.family instance. It should hopefully recognize the associated instances of the family objects.
B
15
S
4
G
4
Posts: 294
Reputation: 3,225

Post » Fri Apr 03, 2015 11:35 am

Hey @Thndr, :)

You might be able to solve this by using "Families" to escape the reciprocal picking that happens with containers.
Manual > Families: https://www.scirra.com/manual/142/families

Setup:
Place the person into a family named "Damageable".

Event:
Hitbox is attacking. // Selects all attacking Hitbox objects.
For each hitbox.
>> Event:
>> Hitbox is overlapping Damageable family
>> Pseron.UID does NOT equal Damageable.UID // Prevents the Hitbox from attacking the Person who owns it.
>> Actions:
>> Damage Damageable. // Deals damage to all Persons overlapping the Hitbox who are not the Hitbox owner.


Note the sub event condition that includes Person.UID.
Here we are assuming that the Hitbox's Person is selected because they are both in the same container, and we're also hoping that won't influence the selected objects in the Damageable family, and it shouldn't, BUT...
If you want to be absolutely sure that the containers aren't involved, and thus can't get up to any of their containerly shenanigans, then instead of getting Person.UID from the Person implicitly selected along with the Hitbox, you can store the Person UID directly in the corresponding Hitbox when the Hitbox is created.

Event:
Hitbox, On created:
Actions:
Set Hitbox private variable "parentPersonUID" to Person.UID.
B
21
S
13
G
8
Posts: 306
Reputation: 5,458


Return to Construct 2 General

Who is online

Users browsing this forum: anty21ro, mystazsea, nimos100 and 12 guests