Point inside an object

It seems there is an issue with checking if a point is inside an object when it comes to the same instance of the object. For example, if I have two land blocks and I want to know if the point of the bottom land block is inside the top land block, this check isn’t working as expected. However, when it comes to different objects, it works correctly. This could be a bug or perhaps some sort of specific instance identifier is needed? Even when using a variable, the issue persists.

Hi there, I never experienced anything wrong with the point inside object. Object picking can be tricky in GDevelop especially when dealing with multiple instances of the same object, so the issue is probably with your events. We need to see your events to know what’s going on.

  1. First, you create an object and define a specific point on it.
  2. Then, you select that object and choose another object for the point to collide with.
  3. If you choose the same object for the collision, it won’t work because the point is inside the object itself.
  4. However, if you choose a different object, even if there are multiple copies of it in the scene, the condition will work correctly because the point will collide with a different instance of the object.

I believe the way GDevelop works is that if you a point of an object_type is inside the same object_type, it just uses the one object_type instance. And because the point outside object will never be inside it, the condition fails. It’s not a bug, it’s the way GDevelop works with instances of an object.

There are a number of work arounds.

  1. If you only want to check the point of one instance, then you can set and x & y scene variables to the position of the point in an event, and in a subevent off that with conditions to select all instances of the object and check whether the point (using the x & y variables) is inside the object.

  2. If there are more than 1 object to check, create a temporary check object at the point for each object, and in a subevent after that select all instances of the object and check for collision between the object and the check object.

  3. To each object add and link a hitbox object (same size, as the object, but hidden). Then check for the point inside the hitbox, and work on the object kinked to the hitbox.

1 Like