How do I select a family instance this way?

0 favourites
  • 11 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Greetings !

    I'm just wondering how I could tell construct to create a weapon from my "weapon family", but only if its variable "type" is "shotgun".

    I guess it's possible, but I didn't manage to find how...

  • on event

    subevent compare family var type="shotgun" > create object shotgun


    on event

    for each family object

    subevent ...

    not sure

  • Hmm...

    The thing is, I would like to avoid a "create object shotgun" action, because it means that I would like to create an action for every weapon type.

    Here's my capx : test

    Here, I would like each wave to create an [enemy], which have the same ID value that the current wave.enemyID.

    Is that possible?

  • You can check the variable after a random family object has been spawned, then destroy it and spawn another one if it doesn't match the other variable.

    Example: FamilyVariableSpawn.capx

  • its this exact feature i would like to see for construct2, a way to create an object of a family based on a variable, this would mean that you only need one compare event and the whole system is set,

    the way its now you have to compare for each object you want to create

    id=1 create enemy1

    id=2 create enemy2

  • Nimtrix

    thats pretty smart, however for optimal performance you should not create maybe 10 objects or more before you get to the right one, but it is a workaround

  • Thanks for your replies. I guess Construct 2 lacks this type of family instance selection...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Canapin

    ive implemented nimtrix example, wanted to see if it would work with the generators

    i changed it a bit and used a for loop, its a bit cleaner


  • That's stunning. I've just fixed a small mistake :

    system -> set choice to wave.enemyID instead of wave.ID

    That works perfectly, thanks a lot !

    Now I'll have to implement the wave patterns... :D

  • Canapin what will the patterns do?, add some kind of movement setting to the spaceships?

  • Yeah, the could come in straight horizontal line toward a direction or another, or make circles or something... Don't really know at this time, I have to work on it.

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