How do I get an instance of an object spawn another?

0 favourites
  • 5 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • I don't mean one object spawning another - I mean how can I get an instance of an object (in this case "fire") to spawn another "fire" instance when the first one is created? I would like to be able to loop it X amount of times so as one "fire" is made it spawns another "fire" which in turn spawns another and so on.

    I'm basically trying to make a fire effect that "spreads" or "grows " around the area the first instance spawned. The individual fire sprites would also lower their opacity slowly and then get destroyed when it = 0.

    I've been fiddling around with it, but all I can think of is having 4 imagePoints on the "fire" sprite (above, below and to the sides) which I use to spawn the second "fire" instance.. which then continues to do that X amount of times. I'm pretty sure what I'm doing at the moment is resulting in an infinite loop (as variations of this technique result in the game not even loading) but I can't wrap my head around it! It's 5am here currently and I've been up for a long time so I figured I'd post here to get some input from the experts, before heading to bed.

    I really hope I've articulated this correctly! I'll bullet point what I'm trying to do... just in case

    -First fire object spawns from external event

    -Fire object spawns a second fire object either above, below, left or right of it(at random) when it is created

    -Repeat X amount of times to create illusion of a "firebomb" spreading from the point of origin.

    -Fire sprites slowly fade, so it looks like they are burning out (I can handle this part...just putting it here for the sake of clarity)

    Thanks for reading and if anyone can help - thanks ahead of time!

    Peace! x

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Why not using particles? I didn't get the point :/

    On created > every X seconds > subtract 1 from the rate of the particles

    This will create a "fade out fire" effect for each instance of the object, as if the fire was fading out

  • I don't want to use particles because, as far as I'm aware, you can't affect the particles that are created by the particles object. My aim is to be able to have an explosion happen, but let it spread through an area. This is because I would be able to delete the individual "fire" instances if they overlap a solid... making it look like the explosion is being stopped by a wall etc. It's pretty hard to explain what I mean...

  • Basically I'm after a way to do a dynamic explosion. So it changes based on objects around it. Just realised this is a much better way to word what im going on about Exhaustion messes with brain functionality haha

  • You can use "Pick by comparison" to pick the first fire, then use a counter instance variable (of that first fire object)

    add1 spawn a 2nd fire,

    add 1 to counter of first fire object, 2nd fire spawns 3rd fire

    add 1 to counter of first fire object, 3rd fire spawns 4th fire

    and so on.

    Just check the value of the counter variable of first fire, you're not going to change anything in counter variables of 2nd to last fire objects. I assume all fire objects have the counter since I adviced instance var but you can use local or global var if you want. You only need to use 1 variable anyway. Then reset if necessary (depending on how you want the fire in your game).

    Pick by Comparison like this example

    Pick "fire object"

    which

    fire.uid (you can use other expressions like IID)

    =

    variable (save the uid of first fire into another variable (of player or global or local variable))

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