Collision groups with independent relations

I am creating a system that restricts access to certain areas using collision groups. A part which fills the space of the restricted area is added to a collision group, group A, and players who should be able to access that area are also added to group A. Collision groups outside of group A can collide with it, so any player not within group A will collide with the part and not be able to enter. However, I need players to be able to access multiple such areas.

My first idea was to add multiple collision groups to a player, however that is not possible, as parts can only be members of one collision group. So, I came up with the idea of a tiered system wherein there exist multiple collision groups which have a hierarchical relation with one another. For example, take groups A, B, and C, A being the lowest level of access and C being the highest. Players within group A can only access areas restricted by group A. Players in group B can access areas restricted by group B and group A. Players in group C can access areas restricted by all groups A, B, and C.

This system requires collision settings between the groups which appear to be impossible to set. For example, objects in group A must collide with objects in group B, however objects in group B must not collide with objects in group A. This relation requires the collisions between the two groups to be able to be set independently, which is not possible. If group A collides with group B, group B collides with group A. As seemingly a limitation of collision groups, this hierarchical architecture appears to be impossible to create due to this issue.

I could control these collisions on the client, and set CanCollide to false if the player should have access, however I want to be able to create these at runtime, not only statically defined, so being able to create collision groups in this manner is important. Additionally, players can use exploits to get into the area, thus requiring me to verify that the player should actually have access to whatever they are interacting with inside of the area on the server before continuing with the interaction (a seemingly avoidable check). Additionally, with Server Authority being released soon I suspect that this solution will become obsolete, as players within parts they should not be will just be set back.

Any suggestions on how to fix this issue or create such a relation between the groups is appreciated.

i think theres no other way to do it than just setting cancollide from the client with your own logic

Why do you want it to be done at runtime? Assigning your custom collision groups with attributes would be kind of the same thing, or you could group them into folders

1 Like

Players are able to create these restricted access areas while they play, so I must be able to create them at runtime. For this I am able to use a simple component system and a central manager for the collision group relations, but without being able to independently control collisions between groups it is not possible in the first place.

I have come to a simple solution, instead of the collision groups themselves being hierarchically related, they can all be independent and I can create a collision group for each player and manage the access to the areas by enabling/disabling collisions between the access groups and the player’s group. This should not be a problem so long as the server size stays small, since there is a max of 32 collision groups. For my use case, I would at most expect 3-6 collision groups allocated for the access zones, and a max server size of 20 puts the maximum at 27 (26+1 for default cg).

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.