How to set different delay for each object to spawn another?

0 favourites
  • 3 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • Hello!

    I want each object to spawn another object with different intervals. In the capx I included the interval time is taken from instance variable that is set to equal object UID.

    Sprite with UID 0 should spawn another object after every 0 seconds.

    Sprite with UID 1 should spawn another object after every 1 seconds.

    Sprite with UID 4 should spawn another object after every 4 seconds.

    But for some reason it does not work :/

    Each Sprite spawns Sprite2 after the same amount of time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There's a fair bit wrong with that code. Firstly you're doing the loop every tick. Secondly, in the function you're accessing param #0, 1, or 4 but you're only passing one param (sprite.delay). You're also not picking any Sprite objects in the function, so all of them get picked and spawn the Sprite2 objects. I wouldn't use a sprite's UID as they are not fixed (maybe in a trivial test like this but not in a real game). Even so a delay of 0 would be just a stream of Sprite2's coming out. There's more, but how about start over..

    PS: I only used IID as a way of getting different delay values, but you could use choose() or random() or anything else.

  • codah

    Thank You!

    Did not even think about timer behavior. This solves my problem very easily

    And have no worries, I was using UID's just for testing purposes

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