Create a family object at runtime....

0 favourites
  • 9 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • I'm attempting to create a family object, and specify it's instance variables, however... the family 'member' it creates is at random. How do I specify which object within the family gets created at the point of spawn?

    Sure... I can spawn that specific object, which is part of the family instead of spawning the entire family... but I'm looking at an alternate way. Any suggestions?

  • I'm actually having this same issue sort of. Help would be apreciated

  • You can't specify which object in a family to create -- the only option currently is to explicitly create the exact object you want.

  • Then perhaps a feature request.... such as, Create family object, where you can specify the ID of the actual family member. It's too bad this isn't possible.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could use the nickname plugin to specify an object to create by name. I believe that's one way around it.

    https://www.scirra.com/forum/plugin-nickname-behavior-nickname_t74522

  • Then perhaps a feature request.... such as, Create family object, where you can specify the ID of the actual family member. It's too bad this isn't possible.

    With respect I'm not sure this really makes sense.

    Like, say you have Sprite and Family1, with Sprite a member of Family1.

    You're saying something like

    System: Create object Family1("Sprite") on layer 0 at (0, 0)

    Right now you just do

    System: Create object Sprite on layer 0 at (0, 0)

    for the same result. Am I understanding correctly?

  • Right now you just do

    System: Create object Sprite on layer 0 at (0, 0)

    for the same result. Am I understanding correctly?

    Here's an example for what I mean.... say you have a family of particles, that you want to create a single one of whenever a certain object of another family gets destroyed (each particle is different for each sprite).... using current methods, this is not possible... unless you did something like this:

    Lets assume sprite1 - 3 are part of Family1, and particle1-3 are part of Family2:

    if (sprite1 gets destroyed) -> spawn particle1

    if (sprite2 gets destroyed) -> spawn particle2

    if (sprite3 gets destroyed) -> spawn particle3

    And so on.... now imagine there were 200 objects!!

    Now, if there was a system in place like I was suggesting, we could do this... First you would need to set instance variables to determine which part of family2 that family1 will be 'linked' to by giving it the name of the particle:

    Lets say that family1's sprite1's variable is set to "particle1", and sprite2 is set to "particle2" etc etc. This could be done at runtime, or in the editor... then :

    if(family1 gets destroyed) -> spawn family2(family1.variable)

    This would be the only line required to have ALL of the family1 destroyed objects spawn a family2 object. I think it'd be a great feature.... if possible...

  • ok well it does look like you're wanting to spawn by name, as FredQ has suggested, but I still think the Family behaviour probably isn't the place to shoehorn that into (IMO). So yeah, Nickname is probably your solution.

  • You could use the nickname plugin to specify an object to create by name. I believe that's one way around it.

    https://www.scirra.com/forum/plugin-nickname-behavior-nickname_t74522

    Just tried it, and it works great! Thanks for the suggestion.

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