Multiple instances issue

0 favourites
  • 10 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • Hi guys, back to development now the kids are back at school but having a little issue. So, adding some more details etc and currently working on some water droplets that drip from a sprite when the animation = a frame.

    So all works, but, trying to randomise the animation of the same instance so they don't all spawn and drop the water at the same time.

    Every random (1,3) seconds > start animation

    sprite = animation frame 2 > trigger once - spawn droplet at image point 1.

    On animation finished > stop animation

    Obviously this picks all instances so they all start at the same time.

    So upon trying to randomise with a timer, on start of layout > start timer

    On timer, for each sprite.uid > begin animation

    This randomises the time for each sprite, however, not every sprite will spawn the water drop on animation 2.

    If I pick all instances and compare the instances that are at frame 2, then multiple water drops will spawn (assume it's counting all the sprites at frame 2 and spawning the same amount of drops for each sprite, but only want it to spawn 1 (but at all sprites at frame 2)

    Sorry for no image/badly written code, on my phone! Cheers

  • If the animation of the sprite isn't important you could set a random animation speed for each sprite, then when sprite animation frame is 2 spawn water droplet.

    If anims must all be same speed you should be able to start a timer for each sprite of a random value then say sprite on timer start animation, this will pick the correct sprite. Then have sprite frame animation is 2 spawn droplet. Do not use a for each with the on timer condition as you described.

  • I'll have another play today, spent an hour n half of head scratching yesterday as to why it wasn't working.

    I did try randomising the animation speed yesterday but same issue of random spawns on animation frame 2, sometimes it spawned, most of the time it didn't. Been sat watching the debugger and watching values etc, pain the the bum

  • If you need more help please post a screenshot of the events, then it should be simple to resolve.

  • On computer now, by the debugged its only picking one instance at a time that has an animation frame of 2. If they are all running at the same animation speed/frame then its fine and will spawn a new sprite on each.

  • When it's a for each instance with trigger once I like to block it out with a variable, so when the droplet spawns you can set a variable on the spawner and in the condition you can use variable is not set, and remove the trigger once.

  • Also tried variables to cancel it out, maybe I'm putting the events down slightly wrong which is conflicting, would you be able to give me an example? Thanks

  • I made a quick sample. I think you are making it harder than it should be.

    my sample uses Wait which normally I try to avoid because people use incorrectly, but it works well here.

    after a dropper spawns a drop I have it wait 2 seconds before the dropper returns to frame 0 to make it less likely to have the same dropper picked for the next drop.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for that Allan, and thanks for your previous help lionz.

    Just used Allans simple example and it works great (although I had to massively increase the times due to the number of instances.

    Subscribe to Construct videos now
  • looks awesome! :)

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