Group and mask

in defold shooter game tutorial,in enemy game object, he added a collision component,and in collision object properties he typed in group the word enemies and in mask the word bullets , how does defold know what enemies and bullets are? defold knows about enemy and bullet because they are two game objects,but how does it know that enemies and bullets means the plural for enemy and bullet? does defold understands the english grammar and can convert a singular to plural?

I don’t think Defold knows english grammar… :slight_smile:

I would say that group and mask are strings (which will probably be transformed in hash internally). Box2d physics engine allows for a certain numbers of mask bits and the Defold engine will allocate a new bit for each new string that is found in some group / mask in the collision components.

I hope this makes somehow sense. At least, I understand it in this way.

Ciao!

maybe i will understand it one day , thanks!

By putting “enemies” in the Group field, you create a physics group called “enemies” and assign that physics object to the group. Then putting “bullets” in the Mask field creates a “bullets” group and declares that this physics object will collide with other objects that are in the “bullets” group.

I’m sure somewhere else in the tutorial, you create a bullet game object with a physics object that has its group set to “bullets” and mask set to “enemies”. That means the object is in the “bullets” group and will collide with objects in the “enemies” group.

1 Like

ah so it adds the collision object into the group, interesting , thanks potota