Allow parts to be assigned to more than one collision group at a time

As a Roblox developer, it is currently impossible to assign a given part to multiple collision groups. This makes it extremely hard to have granular control over physics interactions on locally simulated assemblies between different players.

Use case
In an upcoming project of mine that involves platformer mechanics, I have moving platforms. These moving platforms can move side to side, up & down, diagonally, etc. They are locally cloned & parented into workspace, so every client has their own isolated simulation of the moving platforms for smooth physics purposes. However, other player’s avatars are still considered in the client’s local physics simulation of the moving platform. I.e, if I am on a moving platform that moves up and down, and another player is blocking the way of the moving platform, the interaction between the other player’s avatar and my local platform would still occur, causing the platform to jolt or even stop (this is expected behavior from the physics engine). In order to prevent that from happening, I need to:

  • Create two collision groups on the server, PlayerAvatars and MovingPlatforms, with collisions disabled between them
  • On the server, assign player avatars to the PlayerAvatars group
  • On the client, assign every moving platform part to the MovingPlatforms collision group
  • On the client, locally remove the client’s avatar from the PlayerAvatars collision group to re-enable collisions between the client’s avatar and the local moving platforms

Doing the above prevents other player’s avatars from affecting the physics simulation of your local platforms. This works perfectly fine, however in my game I need to have the player’s avatar assigned to more than one collision group. My game also disables collisions between players via collision groups. Player avatars are assigned to a AvatarCollisions collision group, which has collisions with itself disabled. And as mentioned above, the player’s avatar locally gets removed from the PlayerAvatars group, so I can’t use that to also handle player collisions. In this case, I need the player’s avatar to be assigned to both the AvatarCollisions and PlayerAvatars physics groups, as each group handles seperate functionality in the game (one handling avatar to avatar collisions, the other handling avatar to platform collisions).

Allowing parts to be assigned to multiple physics groups would allow developers to have granular control over the physics interactions that go on in their game with more complex behavior, and would also allow me to filter collisions in the usecase stated above.

6 Likes

If you have AvatarCollisions and PlayerAvatars have collisions disabled with each other, and on the client when you locally remove them from AvatarCollisions, simply add them to PlayerAvatars instead. Would that fix the issue?

From what you’ve described the group’s are very similar, and it’s just collisions with the platforms that you want to toggle. By having two groups that are the same as treat each other as they treat themselves, you just assign them to the other one locally where you want to collide with your platforms.

1 Like