Multiple mask that can be used individually

Hi, so I want to request a great addition to the engine (In my opinion). That is multiple masks to an object. I know that you can already have multiple masks to an object. Want I mean is those mask can be used individually. Like, I can have two mask to an object called “Mask1” and “Mask2” and I can check if “Mask1” is colliding with another object and vice versa. So, for example if I want to check if a object is colliding with it from a specific side, I won’t have to do this:

No_need_of_this

I can just make masks that I can use instead of having to create objects on all sides.

The masks should have another option, that is to change if that mask should be included in the hitbox of the object. Like, if the hitbox option is opted in, it will be included in the hitbox. Otherwise, the mask would be abstract and can only be used to check the collision with another object.

To make it more clear here is a representation:

  • The masks can have different names that can be used in a function to check the collision
  • the masks should have two options, Hitbox and collision mask
    - A hitbox will be included in the object’s hitbox
    - A collision mask will be abstract and won’t be included in the object’s hitbox
    - Both types of mask can be used to check the collision

This can be helpful in many projects, like if you are making a car AI for your game and want to check if player is near the door, you would need to make a object attached to a point and check if that is colliding with the player. And it is another story of deleting that object when the car is deleted. Instead with this, you can just have a collision mask (that is abstract) at the door named “Door” and check if player is collision with mask called “Door” and you won’t need to worry about anything.

Thanks for reading, have a nice day :hearts:

1 Like

So, as a heads up, you can accomplish what you’re talking about right now by just making “hitbox” objects (plain sprites shaped however you want, named hitbox whatever).

Then you add points to your main object where you want the hitbox’s upper left corner to be.
Then just set up events that change the hitbox objects to the MainObjectName.pointX(“pointnamehere”)/Y() of the points.

That said, I think it could be useful for those to be easier, yes.

1 Like

Yes, you can, and I am frequently doing it (That is what I am dong in the first picture). But, it is some what kind of a taped up work and the script to use it becomes very long very quick. And the game will start to lag after sometime. And I started to face issues when deleting the “hitbox objects”. I think making 4 objects for just 1 object is just an overkill. Adding something like that removes all the problems. But, that said, I don’t know how easy it is to add something like this

Hmm…none of the issues you’re describing should occur, as 4 objects for 1 is only 5 objects total, which will not slow down any game unless you’re doing something that’s causing some kind of endless loop.

I have some scenes right now with roughly 200-300 objects that are actively moving (not necessarily all visible on the camera) at the same time, and it runs fine on my PC as well as my Laptop.

Also, as far as I know objects are tracked using the same basic logic as hitboxes already, so if you’re experiencing these issues with 4 objects you’d have the same issues with 4 extra hitboxes.

1 Like

Hmmm, you are right. What I meant was that it will cause more lag (When there is 100s of object) than have one object. Ah, at least the hitbox will not have to display a png.l But, if you hide the object, it also does not display one.

You could end up with lag, but really only if you get into the 1000s of objects range, and you really shouldn’t need that many custom hitboxes for any current modern game type I can think of. (Edit: Remember, even though that you have objects, those hitboxes are only being used for collision detection. You shouldn’t be manipulating them other than movement. Link them to the main object, and then just ensure you “take into account all linked objects” when deleting the main object. This will reduce your number of events.)

Separately, hidden items still fully functions, they are just not displayed in the scene. They work fine for all collisions/events/etc.

You will need to have a sprite of some kind for the hitbox to work for collisions, though. I’m not sure on the specifics, but the engine doesn’t take “sprite objects” without a sprite into consideration for events, I believe.

Again, I want to reiterate that I don’t think custom/named hitboxes is a bad idea. I just wanted to provide alternatives so that you didn’t have to wait for it to be implemented to proceed with an idea you have that may need something similar.

1 Like

I will try that, :blush:

Hope that this feature will be implemented

It would make fighting games a lot more easier to make because I think it’s difficult to make hitbox objects follow an animation.
I did a quick search, it was asked here too:
https://forum.gdevelop.io/t/2d-fighting-game-1/29346

To be clear, it is almost the exact same process to make these hitbox items follow an animation as it would be multi-hitboxes.

The only difference is you are updating Object points for each frame of animation on your object, rather than the object hitboxes. Even with this feature request, you’re still going to have to update the hitbox every frame, it won’t be automatic.

You would still only have 1 event that attaches the hitbox objects to your custom points. You wouldn’t need separate events per frame of animation, or anything.