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

Get help using Construct 2

Post » Tue Dec 16, 2014 10:57 pm

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".

Image

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.

Image

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!
You do not have the required permissions to view the files attached to this post.
B
10
S
3
G
1
Posts: 25
Reputation: 803

Post » Tue Dec 16, 2014 11:23 pm

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.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Wed Dec 17, 2014 12:58 am

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!
B
10
S
3
G
1
Posts: 25
Reputation: 803

Post » Wed Dec 17, 2014 5:34 am

Sent you a PM. :)
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202


Return to How do I....?

Who is online

Users browsing this forum: Ryan Kocourek and 24 guests