0 Favourites

PSA: Families and specific objects

  • 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.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)