How do I Spawn a particular object member of a family

0 favourites
  • 3 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Hello guys,

    First of all, sorry about my english. I know it's very poor but i hope that you can understand my problem.

    Well, i'm actually working on a RPG project, but it's a little bit different from the usual, like action RPG or JRPG.

    So i'm thinking to use a lot of enemies with different sprites and stats, so i chose to use the "family" function, because using the family function i can create instances/variables for all my enemies, for example: Name, Strenght, Defense, Magic Attack, HP... And all of these variables are linked to enemy objects.

    Now i'm trying to "spawn" a particular enemy from this family, however i don't know how to do this action... Is there any way to do this? For example:

    Family: Enemies

    Member: 1) Zombie

    Member: 2) Ghost

    Member: 3) Wolf

    And i want to spawn a Ghost using the family's instances.

    How can i do this?

    When i try to summon an enemy the result is always random.

    Thank you.

    Danilo.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can just create the Ghost object, and the newly created object will be part of the Enemy family.

  • Hello guys,

    First of all, sorry about my english. I know it's very poor but i hope that you can understand my problem.

    Well, i'm actually working on a RPG project, but it's a little bit different from the usual, like action RPG or JRPG.

    So i'm thinking to use a lot of enemies with different sprites and stats, so i chose to use the "family" function, because using the family function i can create instances/variables for all my enemies, for example: Name, Strenght, Defense, Magic Attack, HP... And all of these variables are linked to enemy objects.

    Now i'm trying to "spawn" a particular enemy from this family, however i don't know how to do this action... Is there any way to do this? For example:

    Family: Enemies

    Member: 1) Zombie

    Member: 2) Ghost

    Member: 3) Wolf

    And i want to spawn a Ghost using the family's instances.

    How can i do this?

    When i try to summon an enemy the result is always random.

    Thank you.

    Danilo.

    You have two options to do this. First one is a plugin (as far as I remember) that allow you to do this. However can't remember the name, but maybe someone can?

    The other one which is the one I normally use, is to simply spawn the object that you added to the family. For instant:

    Object Zombie
    Object Ghost
    
    Both of these are in the family Enemy
    [/code:1a89xf8n]
    
    These object have the same UID whether you refer to them through the family or as individually objects. So you can select them both using the same UID, which also means that you can spawn an individual object and still select it through the family. However you still have to respect the picking rules which are very important or you will run into problems. But to explain them, as they are fairly simple:
    
    [code:1a89xf8n]
    Create Zombie
    --> Enemy.HP = 100
    //This is not valid even though Zombie is part of family Enemy it is still a Zombie object. So in this case you would set all Enemy.HP = 100. So you always have to distinguish between Family objects and individual objects. 
    
    Create Zombie
    --> Zombie.HP = 100
    //This is the correct way to do it. As you create the Zombie you automatically pick it. So setting Zombie.HP = 100 will only set it for this Zombie object.
    [/code:1a89xf8n]
    
    Since Zombie is still part of the family, you can still "convert" a pick of a zombie into a Family pick, or what to call it. Which you can do like this:
    
    [code:1a89xf8n]
    Pick Zombie.HP = 100
    For each Zombie
    Pick Enemy.UiD = Zombie.UID
    <Do something>
    
    //Since you start by picking all zombie which have 100 HP, you can pick the corresponding Family object by throwing in a For each and then pick the Enemy.UID = Zombie.UID as these are shared. 
    [/code:1a89xf8n]
    
    Hope that helps.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)