create particular object in a Family

0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • The manual says:

    "If a Family is created, a random object type in the family is picked."

    Is there any way or work-around to create a particular member of a family instead of randomly? If I have a family named Enemy with 4 objects: rat, cat, man, woman and I want to control which one of these spawns, how do I do it? I can do this through events but with a lot of planned enemies, the event list could grow quite long.

    Alternatively, is there any way to control which sprite to create? Say I want to create a sprite with a particular instance variable out of the many sprite objects I may have?

    Thanks!

  • 8 day bump! :D

    My workaround/hack is just letting C2 keep on creating random objects from the Family, checking if it's the right one (through it's instance variable) and destroying it if not.

    However, it seems very inefficient. For example, even with just 4 objects in the Family (1,2,3,4) it can create 1,1,1,1,2,3,2,3,1 when you're trying to get it to create 4. This means potentially a lot of useless actions before I get the one I actually aim for. Problem just gets worse with more objects in the family.

  • Not sure if this is suitable for you. Try nickname plugin/behaviour from rexrainbow

    scirra.com/forum/plugin-nickname-behavior-nickname_topic57943.html

    You can set the enemy object nickname to "Enemy1"(rat), "Enemy2"(cat), "Enemy3"(man), "Enemy4"(woman). So when you want to spawn cat. You just have to pass in "2" as a function param(Assuming you are using a function to spawn) and in the function nickname:create "Enemy" & function.param(0).

    Something like that. However not sure if thats what you want.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the reply! I will take a look at that plugin :)

    EDIT: This looks like it has excellent potential! Now if I can just get around to actually understanding it lol. Thanks again for pointing me in the right direction. That Rex is amazing!

  • Maybe I'm oversimplifying things here, but why not just create rat, cat, man or woman directly?

  • Hi LittleStain,

    Thanks for weighing in! That's certainly the easiest and simplest way but, as I said in the OP, with lots of planned enemies or objects, the list can get quite long. This way, I can store all possible objects to spawn in an array and call them from there.

    c4sp3r89 (little harder to type your name :)

    I've fiddle with the Nickname plugin a bit and while I can't find a way to simplify it the way I think should be possible yet, it's certainly doing the job better than the way I have it right now. Thanks again!

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