[Solved] Point inside an object not working

What is the expected result


This is my event sheet, what is supposed to happen is:

If the Skree is Idle (if it isn’t attacking) and you get to a certain distance to it, the animation changes to Attack. Then, while he’s attacking:

That means, when the “SolidCheck” point is inside a solid object, it’ll stop moving

What is the actual result

It doesn’t stop moving and goes directly through the solid object:
In red = Solid Object
(The 99 is where the “SolidCheck” point is)

Just a hunch, it could be GDevelop doesn’t support points outside sprite collision box itself.
Try resizing the sprite to have some empty space at the bottom

1 Like

Well, I did the same thing with the “Player”:


And it worked just fine
But just to be sure, I tried increasing the size of the sprite, and it still didn’t work

If solid has multiple instances then point is inside is going to compare the point to all instances. Unless the instances all overlapped in that point, it would not be true and wouldn’t trigger the actions.

You might be better off with ray cast

To use the point is inside you would have to either narrow the solid instances to 1 instance with something like pick nearest solid before checking the point.

Or use a NOT (invert) condition with a non-inverted point is inside condition. I’m on my phone, so I used bounding box for the y to test it instead of adding a point.

2 Likes

I have no idea of why using the invert condition, specifically, works
Could you maybe try to explain, if it’s ok? I want to understand what is the actual logic behind this, because the NOT and the Invert Condition are literally the same thing to me

Either way, thank you so much for the help again!

The NOT condition can be confusing and difficult to explain. Maybe someone else can explain it better. If not, let me think about and I’ll try to make a brief explanation although at the moment, I can’t think of a way to explain it without explaining the way Gdevelop works as well.

Invert inverts the condition while NOT inverts the result of the condition. Subtle but it’s different. And hard for me to put into a few words. Maybe later.

1 Like

No problem, it’s ok
I appreciate it either way, thanks for the help!

The majority of conditions deal with object selection, and that is (usually) their primary focus before moving to decide whether something is true or false. This can cause some confusion when dealing with logical selectors or collision, explicitly when you have multiple instances of one of the targets.

I’m going off of memory a bit, but overall for this specific example:

The condition “The point is inside object B” says “Only treat as true if this point is inside a Solid object, then treat as true” (All instances of solid that apply will be selected if they’re referred to in subevents/actions/etc)

The “Invert” version (right-click>invert) of that is roughly saying “The point is not inside an Object B, select that Object B” Since there’s no Object B to select since nothing is colliding, it can’t proceed/treat as true. (it’s much more complicated than this, and has to deal with multiple instances as well, but that’s the easiest way to think of it). You’re almost never going to want to use an inverted “point inside an object” condition, overall.

The “Not” version (advanced condition) of this is roughly saying “Only treat as true if “The point is inside an object” is false” or alternatively “If the point is not in collision with ALL instances of object, treat as true”. This will get you what you want.

3 Likes

I’m hoping a little visual aid will help.

point is inside
There’s1 match, it picks that instance and triggers events

inverted point is inside
There’ are 2 matches, it picks them and triggers events

NOT point is inside (example 1)
There is 1 match which makes it true but the NOT inverts it and makes it false, no trigger

NOT point is inside (example 2)
There is no match which makes it false and would not trigger the actions but the NOT inverts it and makes it true, so the events are triggered

3 Likes

Thanks you both so much for the help! I understand it now

1 Like