wait? being ignored

  • I am trying to get a wait on my spawn, i have a loop that spawns a random amount of enemies, but they all spawn at once, i have a wait at the top of the loop and no matter what value i set it to, they all spawn at the same time anyway, here is an image of what my code is, any suggestions?

    cyborgsattack.com/images/waitignore.png

  • Use a repeat loop.

  • Sorry tested doesn't work, I'll play around with it.

  • Okay, use a sub event of the loop, every X seconds.

  • I need the delay, reason being, the spawn happens, then i need a full second before it moves or half a second to 3/4 of a second because of path finding, then spawn the next, but i don't want a new group to spawn until after the last group has finished, followed up by another random delay. so I'll try adding the sub event within the loop to see if that helps, thanks for this assist.

  • That didn't work, i put in a sub event inside the loop so that on every second, spawn an enemy, once that loop has finished, then the boolean should be set to true that the enemy group has finished spawning. so Wait isn't doing the trick and a sub event so far isn't doing the trick, i'll snapshot my change and post an image for what i currently have, this is only spawning 1 enemy per random.

    cyborgsattack.com/images/subloop.png

  • Try using repeat and setting it up like this:

  • I wouldn't use the else, that may be stopping the loop if you are only spawning one character.

    Create a new save so you can easily go back to your method if you want to build from there.

    What I would do is this. Create a local variable number leave 0, I'll call it "EnemySpawned"

    Create an action that sets EnemySpawn to 0 after the GroupSize action is set to the random number.

    Contain your random with an int so there can't be decimals, int(random(x,x))

    Delete loop condition.

    New condition, System compare - "EnemySpawned" !=(not equal to) "GroupSize"

    change your else condition to - "EnemySpawned =(is equal to) GroupSize"

    add another condition - Trigger once while true

    Start from there, you should be able to take care of the rest but I'll keep an eye on the post.

  • Thanks, i will keep you posted, i've tried many different iterations, apparently the system goes from 1 to N to fast, so while it does reach and surpass N, it doesn't stop the spawn event, so a simple loop with a sentinel that is while condition is true, for instance, i want 10, it burns through say, 278 spawns, so in one loop, it counts up from 1 to 7 but spawns over 200, it really isn't linear like i thought it would be.

    I've watched all of the global variables, gone through debug, kept an eye on my counters, my numbers are accurate and i am now doing the INT thing for the randoms, but the loop literally runs so fast that it both ignores the WAIT delay and it ignores the max count, it just blows through and summons a ton of enemies. Going to take a break from it and go watch a movie, i'll come back and write up another project to share that demonstrates the entire problem later tonight, but there seems to be some issue with the FOR loop and stopping where i need it to stop.

    At some point i need to setup waves of enemies with different amounts to spawn, but can't get that far until this is resolved. Thanks again

  • Persistence pays off:

    cyborgsattack.com/images/workingspawner.png

    I had to do several sub events, plus change how i was adding up the values, this works. Thanks again for the suggestions.

    youtube.com/watch

    See the video for results based on the image i am showing of the setup.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Persistence pays off:

    indeed it does.

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