EVERY SINGLE ONE Separately instead of ALL AT ONCE ?

  • Hi All,

    So I'm making some tests to make my most simple Enemy acts a bit more random by stop, select random direction, then keep going.

    But, I want it to affect EVERY SINGLE of the enemies separate instead of ALL AT ONCE.

    So I've added FOR EACH GooE (enemy's name) but the result now is that it will affect ONLY ONE of them to do these actions, instead all of them at it's own time randomly.

    How can I make it so it won't affect just ONE of them but all of them in separate random time?

    Here is my first attempt with FOR EACH on this event:

    EDIT: I'm getting closer...

    So, I replaced the FOR EACH with 'Pick a Random' GooE, and now it works better.

    It's actually picking a random instance of the enemies, no matter how many I spawn which is great.

    But it's limiting to only 1 enemy at a time, instead of randomly affect the number of enemies or less.

    So if I have 4 enemies, I want it to affect more than just one of them at the same time:

  • |i think if you just swap around it will work eg

    system > every random x seconds

    - system > pick a random gooe > action do whatever

    it wont affect 2 or more exactly at the same time but due to the random timer it has the potential to sometimes change a few within frames of each other which is pretty much the same thing.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the advice NetOne it's working exactly the same, even if I switch the order BUT!

    I found that if I give them a longer wait 2-4 seconds, and shorter pick every 1-2 seconds, they start switching between them.

    It's not perfect but it works for now, I tested it with 4 Enemies, and then with something like 12

    The reason I'm saying it's not perfect is because it can randomly choose only once... the long wait delay gives a tiny spare illusion, so even with 12 enemies on the screen I can notice average of 1 or 2 stops.

    I also tried it without random, with shorter amount of seconds as well (1 second) so I know it's only affecting 1 at the time instead of POWER-UP the action on every single enemy separately.

    I'll try some more tests and maybe I'll get it, I think I'm pretty close to the solution but not there yet.

  • i think the wait is screwing you up as it dosent apply to the gooe

    instead put a timer on each gooe

  • Hey Alon

    maybe this can help you:

  • Thanks NetOne and kriand for trying to help! :)

    I'm afraid it is not because of wait v.s. timer in this case.

    I did some extra tests with Timer (just because it's more accurate and specific than Wait) but I get the same affecting ALL or only ONE enemy instead of EACH ONE SEPARATELY...

    I'm still scratching my head trying to find a solution, it must be some cool feature (loop or something) that I never used before since I'm still learning Construct 3.

  • If you were to implement my suggestion, you would realize that it now works for each object.

    1drv.ms/u/s!Ap_-qxoGKbDcg2GaK0_1xNIMyOhd

  • Thanks for sharing your example kriand I had a look at your file but since my code is much more complex, I'm trying to make this part clean as possible so my question is:

    Looking at my top example, how would you make it work without the "state" ?

    I'll do some tests but I'm trying to find an an alternative way more like in my code where I just put the animation changes without a state.

    I know that what matters is that it works or not, but still... it's my way of exploring and learning as I go. :)

  • I made this because of your other conditions 'is on floor/is moving', in order to keep the timer running. Here is another way of doing so:

  • I made this because of your other conditions 'is on floor/is moving', in order to keep the timer running. Here is another way of doing so:

    Thanks again for the help kriand, I tried to follow your last example but now, the enemies are not even stopping, it's like if I'll just disable the all event... nothing changes, they keep walking.

    There is no other code related to the enemies that damage this, but maybe I missed something:

    And this is my other version, it's almost the same but I change the max speed when they stop or walk like it was before, still nothing affect them:

    It's already 4:24am I could've missed something as I tried followed your example.

    I'm not giving up yet, I'll keep trying probably tomorrow. :)

  • OH MY!!! Just before I went to sleep... I thought about another way, I didn't even need timers.

    It's the first time I used the Instance.Count because I wanted it to work the times of the current instances of GooE (the enemy) on the screen, in case I'll change it's number.

    Maybe it's not the best way but, from what I see on a few quick tests, IT WORKS! :)

  • Your solution is really not the best. Imagine there is only one enemy left. He would stop every second. "Repeat Sprite.Counts times" and then "Pick random instance" does not really make sense either. It could affect one enemy several times and others not at all.

    My example did not contain the complete code to set the sprites in motion, it should only explain the principle. Of course you have to adapt it to your project.

    Here again an example with everything that is necessary. Make sure that the conditions 'is moving' and 'is on floor' are really true. Disable one of the two if nothing happens.

    1drv.ms/u/s!Ap_-qxoGKbDcg2IaHe7qBjaltMzA

    Once again, it shows the principle. Adapt it to your project!

  • Maybe something like this?

    https://www.sizzle-games.com/GooE.c3p

  • OH MY!!! Just before I went to sleep... I thought about another way, I didn't even need timers.

    It's the first time I used the Instance.Count because I wanted it to work the times of the current instances of GooE (the enemy) on the screen, in case I'll change it's number.

    Maybe it's not the best way but, from what I see on a few quick tests, IT WORKS! :)

    I still reckon too complicated and using wait like that will mess things up.

    Better to use timers.

    https://drive.google.com/open?id=1rH2uh5DzwgUeNrXma9vYTY6p4Ymu9XL4

  • Maybe something like this?

    https://www.sizzle-games.com/GooE.c3p

    sizcoz I had a look on your example and it works great!

    I have a few questions since I'm still learning:

    1. Can you please explain to me why the random is 2-4 ?
    2. Why did you put the same random also on the "On start of layout"
    3. If I want to tweak, I need to tweak both?
    4. Will it work on only 1 enemy or 100's enemies? I'm a bit confused that's why I'm asking.

    I'm trying to understand the code so I won't just copy past like a robot.

    Thanks ahead to everyone who help in this, I appreciate it a lot! :)

    EDIT:

    In your example, they start moving at start while in my case they always starting not moving.

    I see that's because the GooE_random initial is 0 but it supposed to use random(2,4) so they always start moving, but they're always start standing all together.

    I'm not sure why it's working on your code but in mine it's not, if I change it, they all freeze at the same time when the game starts.

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