Trouble with a For Each loop

From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies. For use in game and custom works.
  • Alright, last night I got into a fight with my script cause it didn't seem to be working right, and now after much tinkering I still can't straighten it out. The part in question is this:

    When enemies get within 300px of the layout border, they're told to go back. This seems to work... intermittently... and apparently when the condition is true for ALL enemies at once. I thought a For Each loop would solve this, but seems not. In my attempts to rectify it, I've tried moving the For Each into every which place on the chain and breaking up the events into separate blocks. Probably other things too that I don't remember.

    What gives? If this looks sound, perhaps something else is causing the AI to misbehave.

  • Does the layout have scroll?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Scroll To behavior? It does.

  • I mean if the layout is larger than the screen size, this would mean that the game has scroll, it is not a single static screen.

    So, do this test:

    Change layoutWidth to originalWindowWith

    layoutHeight to originalWindowHeight

    That for each I think it will not be necessary

  • Oh, yeah, the layout is substantially bigger. In theory I can punch in the actual coordinates and make it "when X > 1200" or whatever but I figured this way allows more wiggle room if I wanted to use layouts with different sizes.

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