Trouble with a For Each loop

0 favourites
  • 5 posts
From the Asset Store
SynthWave Loop Pack
$3.50 USD
50% off
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • 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)