PSA: Families and specific objects

Get help using Construct 2

Post » Thu Apr 21, 2016 4:40 pm

Short version: You can assign instance variables to objects themselves before they are created as an instance, which remain true when they are created. I used this to narrow down the random Family object creation.

Long version: I was struggling with a need to create random object instances while also needing to limit what could be created from them. Specifically I wanted to create sprite people who could be either male or female but they were lumped into the same Family for easy spawning but I had no way to know which were male and which were was female (from event perspective) so I couldn't further more specific characteristics to them such as random female names, and random female names which corresponded to their appearance.

It finally dawned on me that you can set the instance variable directly to the object and it holds that value on creation, thus I can create objects using the family, then check when they are created if it holds a male or female variable and assign further attributes accordingly.

I hope this helps someone else out there, though it may be obvious looking back.
B
10
S
2
Posts: 77
Reputation: 989

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest