[Solved] "invert condition" isn't work properly? how work instances and multiple objects?

I have an object group (triggers to buttons in the UI), thats fine. I want something happens, when the mouse cursor IS NOT on this group (but anywhere else) and the left button is pressed.
I put the “left mouse button is down” and the “the cursor/touch is on my object group” conditions to an event. and it doesnt matter I invert the “the cursor/touch is on my object group” or not, it behaves the same way, execute the action. it ignores that I inverted the condition.
did I misunderstand something, or this is a bug?

I reproduced your issue, and it happens the same for me. I thing it’s a bug.

1 Like

thank you for your efforts. I cant saw it in the bug reports, thats why I asked here.

I am 99% sure this is not a bug from the invert, but from the group. The invert just looks if it gave him a true and make it then false or if it gave him a false then make it true.

3 Likes

yes, when I do it with a single object, everything is fine! ty

This is actually coming from the invert condition. Even if you are using it on a group, if the mouse is NOT on any object form the group, it is going to return true so that’s why it is execute the action because there always be 1 object from the group that did (not) meet the condition.

I remember was reporting this problem years ago and told it is not a bug considering how the engine works internally, it is the expected behavior.

But I agree, when you invert this condition on a group it should take in to account all members of the group and return true only if none of the members of the group met the conditions :+1:

Usually you can solve this kind of problems by using the For each loop, but it can be heavy on resources, need to be careful with it.

1 Like

I’ve solved same problem here :


Let’s go back to basics :

  • An object is: An object that you create in the object list.
  • An instance is: When the object is on the scene (One time or multiple time ).

The event sheet simplifies things by talking about objects. But basically it works with instances.

When you put the object in a group. And that you call the group.
What is used by the engine is the list of instances.

The event sheet contains a kind of selector in the game engine.
When you call a group, this selector will contain a list of instances of the objects present in the group.

Your condition is “if the cursor is on group XXX”…

If you have understood correctly, this will select a list of instances of the object in the group.

The game engine will take the instances one part one and test the condition.
Is the mouse on instance A? Yes, we do the rest of the events.
Is the mouse on instance B? No, we stop, we’ll see the next instance.
This for each instance…
You have invert the condition. So the game engine will understand Yes by No and No by Yes. This doesn’t change very too much.

The engine will then check if all the results are identical for all instances.
As there are Yes and No’s the engine will refuse your condition.
And there for you it doesn’t seem to work you said this is a bug. For the engine everything works well, the game engine is happy with it :slight_smile:

What you need to tell the engine is to check this action for ALL instances.

So create the event “For Each” , this is a loop.

The event will display “Repeat for each XXX object”.
XXX is your group.
Then you put the actions in under event.

In few words :
If an object is present only once on the scene (Only one instance) then it is useless.
If there are several instances of the object on the For Each scene is mandatory.


More info on groups:

A group of objects allows you to put several objects (a sprite object and a text object for example) in the same list (Group).
This group of objects is understood by the game engine as a list of instances of the two objects on the scene.
if you have on your scene 3 sprite from the object A, and 2 Text from object B
The group is like this :

group = [sprite, sprite, sprite, text, text]


I hope I didn’t say anything stupid or wrong in my explaination ^^

1 Like

thank you for this detailed explanation. really, I missed some things, but now I understand how object groups work. nonetheless I have reservations about this.

this action’s name is poorly worded and misleading.
when I select it from the menu , its said “the cursor/touch is on an object”,after that it allow me to select not a single ojbect, but a whole group from the list. this suggest the group will act as a single object! a great mass, what contains all instances what I add to, behave as if it were one.
in the other post what you linked I read lot of users encounter with this problem. may be it is not a coincidence.

Maybe theses terms are less confusing :

Original : Repeat for each XXX object:
Suggest : Repeat for each instances of object XXX

Original : Pick all XXX objects:
Suggest : Pick all instances of XXX object:

@Gyuszko @ddabrahim @4ian what do you think ?

I’am familliar with GDevelop only.
I’am wondering how this work in other game engines.

In other game engines they use the correct programatical name for things, like class and instance instead of object and… object.

1 Like

The suggested terms are more accurate but the truth is by end of the day each engine using their own terms for certain things that we just need to get used to what it means and how it works like Actor, Entity, Object, Sprite, Group, Collection, List, Prefab, Blueprint, Template, Node, Scene…etc

Now you might think, Object, Sprite straight forward but no. In other engines Sprite may mean just the image in the game while in other engines it is referring to an Object while Object you may think is the instance in the scene while in other engine Object is referring to a Template while in other engines Template is referring to a complete game template not just an Object in a game…etc.

So my point is, every single engine out there do have it own terms and learning curve. People need to get used to what each term means in the engine and how it works. :+1:

3 Likes

The problem is I have only one instance of each object (3 different sprites and 1 text) and get the same issue.

so, in my case:

original: The cursor/touch is on xxx object
Bouh: The cursor/touch is on any instance of xxx object

original: The cursor/touch is on xxx object group
Bouh: The cursor/touch is on any instance of xxx group
or inverted: the cursor in NOT on any instance of xxx group.

nope. sorry. this still means for me, the cursor isn’t on the group. isn’t any part of it. no matter what you are call them, objects, instances, object instances, or what.

now that we rephrased it, I realized that the problem was not the name. but its functioning! we call it a group, but it isn’t correct, because it isn’t behave as a unit. it is just a “for each” event, nothing else.
you say it should work like a for each event, because it should check every instance one by one for the correct result. and you’re right up to this point. but the key of this problem is just after this point. the conclusion of the independent tests. because no matter how many member on the group, it is still a condition, so it can’t give more output, but one!
as you explain, the engine test all instances in the group separatly, one after another. all independent tests has his own result. a final conclusion to be drawn from them to the condition can give only one output. it’s still fine, but what happens, when I invert the condition? the engine perform the independent test with the opposite of the condition, conclude the results and give an output. and the error is here. if I invert a condition I don’t want invert the for each events independently, because I want the whole group work together as if it were one single object. on my opinion the engine should perform the test as originally, conclude the results and invert THAT, and give output accordingly.

For"for each"/“pick all”/etc, it’s indeed more correct to display “instances of XXX” :slight_smile: If you want to do the fixes I’ll be happy to accept them.