[SOLVED]How do I use instance variables in a family to spawn objects?

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi I'm trying to spawn bullets from a gun and can easily do that but I am a bit at a loss on how to expand my functionality.

    I am trying to create a family to hold all my various bullets with a family instance variable of bullet_type so I can uniquely identify each bullet and switch types. My end goal is to use a global variable compare to select the correct bullet to spawn depending on powerups. The spawn object action asks me to specify a specific object though. Is there anyway to do something like:

    spawn family object where instance variable = power_bullet

    or something?

    Any suggestions about how to go about this?

  • No, this is not possible. When you spawn a family, a random member of the family will be created.

    You should use "Create by name" action. For example:

    Create object by name "Bullet"&BulletType

    After that if you need to change any bullet property, add a sub-event "System pick last created BulletFamily" and there you can set bullet angle, speed etc.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No, this is not possible. When you spawn a family, a random member of the family will be created.

    You should use "Create by name" action. For example:

    Create object by name "Bullet"&BulletType

    After that if you need to change any bullet property, add a sub-event "System pick last created BulletFamily" and there you can set bullet angle, speed etc.

    Thank you! Just incase anyone in the future stumbles upon this here is a visual representation:

    Just toggle the bullet global variable to the bullet object's name you want switched to.

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