Inactive enemies still perform action; can't filter them out

0 favourites
  • 4 posts
From the Asset Store
Alot of High Quality Items sound effects for your game!
  • Hello! Thanks for taking the time to enter my topic. I've been trying to fix that for like 10 hours. Tried many different things, all fail.

    Overview of what I need and the issue I have with it:

    -I have different colors of enemies (color families), and the user can make one color at a time disappear from the screen (they become invisible, solid becomes disabled, and they get pinned to background :: that's what I'll mean in this topic when I say an enemy becomes "inactive"). To make it simple, in my example the user simply presses the arrow keys to decide which one becomes "inactive".

    Issue: When an enemy walks in front of an "inactive" enemy, the inactive enemy isn't filtered out correctly and performs an action that should only be performed by an active enemy. In this case, the inactive enemy currently going to the right changes direction ("go_left" boolean variable becomes "true"). I tried to fix that for 10 hours, trying many different ways to filter it out, but everything I try fails. In my last attempt, which is represented below by the sub-events, I tried to use the enemy graphics and then in my last attempt even added a ridiculous opacity check (the inactive enemies now also get their opacity set to 50) so that they would be filtered out for sure, but it still doesn't work. I have no idea why the opacity check doesn't work.

    One thing I noticed, it seems that the issue only occurs with the "inactive enemies" with Go_Left set to False. If Go_Left is set to True, the issue doesn't occur and they don't change direction. Which means to reproduce the issue, make an enemy inactive while it is going to the right, wait for the other enemy to walk pass it, then make the inactive enemy active, and you'll see he changed direction.

    One way to fix the issue easily would be to code every color family separately, each having their very own "Go_Left" variable. However, that would mean having 4 times more code for everything that has to do with them changing direction (there will be 4 colors in total), and thought it might be the "lazy" way out for me, and that there's probably a better way to fix the issue.

    After 10 hours it is getting me insane and thought it would be a good opportunity to ask for help for once. The capx file is attached. Thanks!

    Note: I don't know why the pics don't appear here, but if you right click them and copy the url you can check them out!

  • The problem you are having is because you are setting 'go left' with overlap tests. Disabling solid does not disable collisions; consequently, enemies still overlap, and the var still changes. However, when I fix this by disabling/enabling cols when toggling between types, go left is always forced to 1 because one of you events is 'is NOT overlapping, set go_left to 1'.

    Honestly, at this point I stopped. I'm sorry to say this, but your code is simply a mess. You have way too many overlap tests, families, and other convolutions. I feel for you, really, I've ended up with code like this myself, but you are going to have to take a fresh stab at this, and build it from the ground up, because what you've got is inefficient and unmaintainable.

  • Thank you for the feedback! So, that's why I can't disable collision... good to know.

    Yeah I noticed it's now a mess, the more I tried to fix my issue, the messier it got.

    And all the sub-events are just "patches" I put up on top of it, trying to fix the issue, and can all be removed.

    The "If enemies are not overlapping with the platform at offset" was a way I found to make enemies turn at the edges of platforms without having to put edge markers at every platform edges. I guess I'll have to either tweak it or scrap the idea completely. (EDIT: I'm scrapping it) That way, I'll be able to just "turn collision off" on the enemies and eliminate most of the mess I shared in this topic! lol

    I actually tried turning off collision before, like you yourself tried, and got the issue you mentioned, but couldn't understand why.

    Thanks again!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sent you a PM.

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