Need to pick same objects with different variables for different actions on each

both groups have same objects
is it really not possible to do pick objects with different variables like that? (map is to test, map is not deleted and there are both enemy = 0 and enemy = 1 entities)


heres another try

entities is the attacker and entities2 is target basically
im trying to pick each one out and then do events with them
so that i can have any entity objects fighting each other on any team i want
but it seems like nothing just works
it just doesnt like picking from same object pool or something
so i wonder if anyone knows how to do that or a more clever solution

I assume that entities and entities2 are both object groups containing all of the same objects. I have tried this method as well and it can work in some situations, but the problem is that anything that is true for an object from entities will also be true for an object from entities2.

Since these object groups contain the same objects, try reimagining the logic with just one group. We’ll just call it “ObjectGroup”. In your first event you have conditions for variable “enemy”. Let’s go step by step:

  • Pick everything from ObjectGroup with variable enemy = 0

Ok, we have all ObjectGroup objects with enemy = 0. Next condition:

  • Pick everything from the current list of ObjectGroup objects with variable enemy = 1.

Uh oh… see the problem? We already filtered the list of objects to only include ones that have enemy = 0. Now you’re asking to pick, from those, the ones who have variable enemy = 1. Obviously, there are none - you already picked the enemy = 0 ones, so among those none of them will have enemy = 1.

Even though you named the groups differently, they consist of the same objects. I’m pretty sure that the objects are all being filtered together here. There is only one pick list for each event, using a different group doesn’t make it so that there are two separate lists. I think it can potentially add new objects to be subject to filtering, but still all within a single list.

I say I’m pretty sure because I’m actually not 1000% positive about this and might need to be corrected…

Anyway, my solution would be to use a separate target object for any of your entities that can attack. This could be a blank sprite, or some sort of crosshair or indicator if you want (especially during testing). You would create it alongside the entity and Link them together. The target object will handle searching for entities on the enemy team, with a variable to indicate that it is locked on to a target.

Then you can have an event to check if the attacking object’s linked targetter is locked on, this way you don’t have any overlapping object groups.

yep i understand what you mean with the filtered objects. but why wouldnt the
the variable enemy of entities2 != entities.enemy
condition work?

the target object solution is something i could look into, but i would LOVE if i could get the current one to work, since i kinda built around that already

Because they are the same group of objects. You’re essentially trying to pick the objects whose variable equals 0 and 1 at the same time, which is impossible.

It is possible to get around this by using “Pick all objects” and “Unpick objects” (unpick is from the object picking tools extension, you don’t have it by default). But, that is kind of a hacky way to go about things, I’ll admit that I have done it but using an object based solution is probably a better practice.

You could also look for behaviors that will provide this functionality for you, might save a lot of headache :slight_smile:

If you just want an object from each type, you could use an OR condition. I used an OR with AND conditions so I could limit it to 1 object.

I used the flash behavior for testing.

If you wanted to be able to control the objects seperatly, you could use variables to hold the positions and object variables to flag them. I used attacker and target object variables and similarly named scene variables.

This moves each object towards the other object. I added stop for testing, so I could press the button repeatedly.

i need them to do actions with both groups in same action/event though

What do you need to do? It’s not easy to interact directly with instances of the same object. A workaround is to use variables to hold the value of one of the instances like in my 2nd example. Everything depends on what you need to after they’re picked.

My first approach using OR would pick an object from each entity although, it would be difficult if they were the same object and needed to be treated differently.

It’s easier when the objects are different objects not just instances.

most of the game involves fighting heroes (different objects) fighting enemies. some heroes have roughly same attacks but different abilities, so i want to have 1 chunk of code that does that. and i also want to use same code for enemies hitting heroes. i could for sure do 2 groups for enemies and heroes and just make this code for heroes hitting enemies and then copy paste and make the enemies hitting hero one, BUT if i can make any set objects fight it would make stuff such as multiplayer pvp duels possible. I guess i could make the 2 group solution, but its still a bit clunky since its 2 code blocks that i need to both change identically each time i make a change and for heroes vs heroes gameplay id have to think of some brand new system.