Create family instance where variable = x

0 favourites
  • 12 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • I have a family of objects and i create a random one by using

    System -> Create object MyFamilyObject

    I know this works in a way that it will select a random instance in the family

    What I would like to do is filter what it selects from based on an instance variable of the family

    The idea is the family object holds all enemies, and i spawn them randomly but i would like it to just spawn the enemies for level1 on level1 using an instance variable called LevelNumber, hope i am making sense

  • You have to write a condition for each enemy type and create exactly the object type (family member) of the enemy if the condition is met. But than you can access them through family object.

    if varEnemy="Goblin"

       -> create object type "Goblin"

    if varEnemy="Troll"

    -> create object type "Troll"

    It's a pity you can't do it with a variable of the family object. There are also some workarounds with different animations for different enemy types:

    construct.net/en

  • Thanks for getting back to me, I'll go with your suggestion above, bit of a pain but the alternative is having all the same enemies in all the same levels which would kinda ***** thanks for replying so quick!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • How do you access them through the family object after you have created them?

  • Ah i see you can access it by family object if the sprite was created in a parent event, nevermind this is too complicated

  • Calm down theames, do you have any CAPX to share?

    I can write a extensive post here, but you would prefer read direct to the font:

    http://www.scirra.com/tutorials/361/understanding-uid-iid-health-cards-and-rocket-smoke-trail

    http://www.scirra.com/tutorials/355/making-character-composed-of-multiple-parts

  • Thanks for the links but they don't really cover what I'm trying to do. I have a family of enemies and I want to select a random object from the family to create. But I don't want to pick from ALL objects in the family. Just where an instance variable is a certain value

  • theames xoros

    this is a solution to create from a family by name

    by creating a random object from family but only keeping the one you need

    in this case the objects are wood or stone but are from the same family

    example

  • vtrix

    seems to be a good work around, but I think it will not always work if you would have like 50-100 objects

  • xoros , yeps its a workaround, use it where you can, not sure at what number it would become a problem, you could up the loopnumbers, i been using it for 20 objects and works very good, i would also like a better way but there isn't for now.

  • In this topic:

    construct.net/en

    I asked if it's possible to solve the issue with a third party plugin? May be anyone can comment on this?

  • vtrix

    Thank you so much for your solution it was exactly the sort of thing I was looking for.

    I agree it's not ideal when you have loads of objects in a family, but I'm looking at there being <50 and this seems to be working out just fine for me

    Thanks everyone for the contributions <img src="smileys/smiley32.gif" border="0" align="middle" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)