Ho do I create an else condition that is applied to the inverse of the current sol?

0 favourites
  • 8 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Lets say I have:

    A overlaps B -> set A.somevar to 1

    Else -> set B.somevar to 0

    The else statement will never run if a single A is overlapping B. What I want it to set any remaining A not picked by the first event and set somevar to 0.

    I can't afford to duplicate collision checks or run for eachs. Both are costly from a performance standpoint so the best I have is:

    EveryTick

    ---Set A.somvar to 0;

    A overlaps B

    ---Set A.somvar to 1;

    A.somvar = 1?

    ---Do the things

    A.somvar = 0?

    ---Do the other things.

    Its seems verbose, has more events than it should, and still duplicates the number of checks. Is there now built in In case of A do this or B do that?

  • You can say if A is overlapping B then set to 1. If A is not overlapping B then set to 0. So the first one but right-click inverted.

  • Unfortunately, "Else" block doesn't pick instances. Your workaround is pretty good, I would've done the same. You can optimize it a bit - move "Do the things" inside the "A overlaps B" event.

  • dop2000 good suggestion. I had it combined, and for whatever reason uncombined it and I don't remember why :/

  • You can say if A is overlapping B then set to 1. If A is not overlapping B then set to 0. So the first one but right-click inverted.

    That duplicates the collision check though, right?!

  • > You can say if A is overlapping B then set to 1. If A is not overlapping B then set to 0. So the first one but right-click inverted.

    That duplicates the collision check though, right?!

    Why does that matter? Your workaround is running every tick

  • Why does that matter? Your workaround is running every tick

    I'm guessing one overlapping check + one variable check is less costly than two overlapping checks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • > Why does that matter? Your workaround is running every tick

    I'm guessing one overlapping check + one variable check is less costly than two overlapping checks.

    Definitely, the performance difference will depend on how many objects you have, but it will remain true for even small object counts (though, the philosophy of when to optimize should be considered in small count cases)

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