instance spawn another instance of itself

0 favourites
  • 6 posts
  • Hi,

    I want an instance to spawn another instance same as itself but different size on a condition on the first instance.

    I have a bug with collision with a bullet I want to spawn another smaller bug and destroy the original bug.

    how can i do that?

    thanks.

  • have you tried the system event create object?

  • You need a kind of flag to differenciate the two for picking.

    Create the boolean instance variable 'destroyed' on your object with default false

    and then

    Mouse: on object left click
      -> Object: set destroyed to true
      -> Object: create object on layer 0 at Object.X+50,Object.Y
    Object: is destroyed
      -> Destroy

    This way, when you left click on the object, another one should be created 50px to the right and this one should disappear into nothingness.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • thanks Yann.

    also is it possible to do a loop if i want to create multiple instances?

    or just do multiple actions of create object?

  • Mouse: on object left click
      -> Object: set destroyed to true
      System: repeat 10 times
        -> Object: create object on layer 0 at Object.X+50,Object.Y
    Object: is destroyed
      -> Destroy

    hmmmm should work

  • works.

    i wonder why i didnt even try it.

    also in case someone will find this useful

    instead of bool for destroyed i used int value that is decreasing on new instances from the main obj and on the main obj it becomes 0.

    on each obj that reaches 0 i destroy it.

    then i can multiple levels from big bugs to lowest and then destroyed.

    thanks.

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