Point Inside Object when Objects are overlapping


I’m working on an isometric game, which means many of my objects, like floor, are not rectangular, but the full object area always is, and as a results, the floor objects will always overlap.

I’m trying to play different footsteps sounds depending on the floor type using Point Inside Object.

The Issue

The problem is that when two objects overlap, the sound will stop, because the condition “player is inside object” is no longer valid, since the player is in fact in two different floor objects at the same time. See the screenshot below, where the Grass object is overlapping the Ground object:



Is there any way to avoid the the object overlap in an isometric set up?
Or play the correct sound depending on the floor type even if it’s overlapping with another type?

I can see your problem, here’s a link, someone asking the same question, 2nd link is the answer, not sure I understand it yet or how to implement it in gdev as it’s in java, but will give it a go!


Thank you so much for replying!

I’m afraid that the solution you provided is way beyond my comprehension of coding or maths.
I was hoping there was some way to make it work directly in Gdevelop using some of ready made behaviours.

I can’t be the only one who’s faced this issue in Gdevelop and hopefully someone has found one of those the widely advertised “no-code” solutions :sweat_smile:

You could use the pick nearest object as the last condition or maybe save the last value or current sound and somehow only change the sound if it’s not one of the tiles. I’m not sure how to implement the 2nd one. I’d have to try it.

If the collision box matches the visual shape, it would only trigger when inside. There could be a gap between tiles but you would only change the sound when there was a tile anyways.

You could check multiple points and somehow make a decision based on both. Again, I’m not sure how. I’m a but distracted at the moment.

You need to edit your collision mask to fit the visible tile instead of the whole rectangle. Also the Isometric example has a simple setup for using sound on one specific type of tile which would be easy to modify for multiple tile sounds.

Isometric game - a game example from the GDevelop game making app | GDevelop

Thanks @Keith_1357 and @Lucky-j.

I was had tried the collision instead of “Point inside object” but I couldn’t make it work before, but now I tired again and it did work! So, thanks for suggesting it.

Though now I have a new issue :sweat_smile:

On the border of two tiles, the character’s collision mask will cover two tiles at once, so two different sounds will play at the same time.

I saw that I can create multiple collision masks, so I can make the mask smaller for the character, but I don’t see a way of picking which mask should be the one that is used for the collision with a specific object.

Is that possible to do?

You can use a custom mask with point is inside. If the objects no longer overlap then it should only pick 1 object. Either way, you can still use pick nearest object from the players x,y or whatever point ot object.

The collision mask is per animation or animations.

Yeh it’s possible to do but is it practical in your game? For example in my project, I have buildings and decor that the player can move and place as they see fit. I absolutely need the collision mask to match the visibile shape of the object at least, so they are able to drag it. So animation0 collision box is that. But when dropping, because it is isometric, I need the collision box to only be on the base of the item and only as big as how many tiles that item will fit on. Otherwise it may “collide” with another item placed in an adjacent tile and be sent back to its original tile, infuriating the player. So animation1, with the appropriate collision mask, is used briefly in events when an item is dropped.

But… I assume your game is going to have monsters or something attacking the player while the player is walking. So I’m not sure if changing collision masks in different situations is practical in your game.

Edit But anyway the Isometric example uses point inside, and it would be an easy route for you to go. You still need to edit your tile collision mask for the tiles and then create a point inside the feet for the player.

Thanks @Keith_1357, @Lucky-j.

I’m already using custom collision masks matching the art for all assets, and I set up the “Foot” point for the player, but that wasn’t working, because of the original issue I mentioned.

Can you explain a bit more how to use the “point is inside” with a custom mask?
As far as I can see I can only use it with an object which uses the entire object area and not the collision mask.

Regarding the “pick nearest object” I will also need to do some research, as I’m not sure how that functions.

For me, point is inside works with the objects collision mask. It’s in the description.

Pick nearest does as the name suggests if multiple objects are picked, it chooses. The one closest to the supplied point.

Point inside is a collision event. It is actually much simpler to use point inside in isometric collision detecting, I think, than regular collision events. I don’t always use it though, depending if the events I am using it for will eventually need an inversed point inside event. Because I don’t understand those. Keith can explain them over and over to other people in the forum and they all understand but I just don’t. So for logic that would eventually call for an inversed point inside, I use regular collision events instead, although they can be a bit more involved to set up. So how it would work is your character has a custom point that you gave it.

So for example from this tutorial, you see the land image is a huge rectangle with a collsion mask the size of the visible part, the scythe is a small draggable object which interacts with the land to cut crops - for player convenience in dragging, the collision mask is the original whole size of the image. Then the circle is showing where a custom point was put in the scythe. When this point is inside the land object, it will cut down any crops growing there. But because point inside is a collision event, it only checks to see it the point is inside the collision mask part of the land image.

Thank you @Lucky-j , @Keith_1357 ,

I made it work. I realized why the “collision” wasn’t working and got it to work with the “point is inside”, though, still not completely as expected.

I can start the sound with “point is inside” but not stop the sound with the inverted logic. For stopping the sound I did have to use “collision”.

Here’s a screen, perhaps you can tell me why one is working but the other one isn’t?

Also, I still cannot figure out the “Multiple Collision Masks”.
I don’t know when or where I can specify which mask should be used for the collision, I can only say what object, but not which of the collision masks that the object might have. Any tips?

I’m not sure I understand your question about masks. Objects can have 1 mask for all animations or seperater masks for each animation or for each frame. The mask setting and the current animation decide which mask is used.

If you had an animation of someone swinging a bat you could align a mask on each frame to follow the bat. So, it would collide in the right spot. Most of the time that type of accuracy isn’t needed and the same rectangle or loose shape is enough. You usually want the mask to loosely fit the image. When the image is small, nobody will notice the difference between a perfecting fitting mask but the more complex a mask the more it takes to process each one on each frame of the game.

There are times when you need 2 masks or 2 objects. So, you can use a 2nd hidden object with the same or a different mask but this should be used only when absolutely necessary because again resources.

As for the point is inside. Sometimes inverting a condition doesn’t work as expected and you need to put the non inverted condition inside a Not condition.

This can be confusing.

This might help.

Thank you for the tip about the “NO condition”, I’ll give it a try.

Regarding the masks, this is what I mean:

I’ve got a single animation, same frame and two separate masks.
Perhaps that’s not the intended use, but Gdevelop allows it, so I figured there must be a way to make use of them. :person_shrugging:

You can use multiple shapes but to my knowledge they are merged into 1 mask. I’m not aware of a way to check them separately. Your best choice might be to use 2 objects. You can use actions or the sticker behavior to keep them in sync. A lot people use separate hitboxes.

1 Like

Thanks, that makes sense, you’ve helped me a lot :slightly_smiling_face:

I’ll try out the two objects method.

1 Like