Simple collision question

How do I disable inter-character but enable intra-character collisions for an arbitrary number of characters, with total limb count possibly exceeding 32?

Is there a workaround for the opposite of NoCollisionConstraint?

1 Like

I guess you could

  1. When a player joins, register a collision group for them (e.g., trigophi_character)
local collisionGroupName = player.Name.."_character"
game:GetService("PhysicsService"):RegisterCollisionGroup(collisionGroupName)
  1. Add the collision group name to a predefined table containing character collision groups
characterCollisionGroups[player.Name] = collisionGroupName
  1. Loop through said predefined table and use CollisionGroupSetCollidable to disable collisions
game:GetService("PhysicsService"):CollisionGroupSetCollidable(collisionGroupName, otherCharacterCollisionGroup, false)
  1. Set collidable with itself
game:GetService("PhysicsService"):CollisionGroupSetCollidable(collisionGroupName, collisionGroupName, true)
  1. Loop through all the limbs in the character and set their collision group
limb.CollisionGroup = collisionGroupName 

You can set collision groups on the server, and then assign them on individual clients. So your nocollision group would be assigned on the client when they spawn, but for everyone else they would be the default collision group.

I forgot to say this, but, I want to mention that I am aiming to apply this to a number of characters that may exceed 32 (NPC & player character interactions).

How would I scalably make NPC characters pass through other characters while having limb collisions within themselves?

You can do all that with RegisterCollisionGroup helloig1oo1 has it.

Am I missing something? Isn’t there a limit to how many CollisionGroups can be registered?

“I forgot to say this, but, I want to mention that I am aiming to apply this to a number of characters that may exceed 32 (NPC & player character interactions).”

I missed that detail .. Maybe not.

1 Like

It might be a bit inefficient, but you could just enable both inter- and intra-collisions, and then usage NoCollisionConstraints to disable inter-character collisions.

It would require a massive amount of instances however, which is obviously a pretty big downside.

1 Like

Create 2 collision groups:

  1. LocalPlayer
  2. OtherPlayer

LocalPlayer can collide with LocalPlayer
LocalPlayer cannot collide with OtherPlayer
OtherPlayer may be able to collide with OtherPlayer depending on whether or not you want npcs to be collidable with one another

Set NPC and each player’s character collision group to “OtherPlayer” on the server
Set the localplayer’s character collision group to “LocalPlayer” on the client

When making the localplayer’s limbs collide with the localplayer, set the limbs’ collision groups to localplayer and if needed use NoCollisionConstraints where necessary

2 Likes

yeah pmuch this is the answer

1 Like

Do you mean while having limb collisions with themselves?

Oh yeah typo mb, I’ll edit that

I was going to try this, thanks for the suggestion. It still won’t work for NPCs though

Didn’t know it’d be possible

Should NPCs be able to collide with other NPCs?

No, and I’ll restate my problem for anyone still keeping up with this thread:

I define characters here to be any physical model representing an NPC or a player’s character

With that said, I want:

  1. Distinct characters to be able to pass through each other
  2. Limbs within the same character collide with each other

I didn’t know that setting collision groups on each client was possible, so thanks for that info. Despite that, I don’t think this will work for disabling collisions between NPC models while preserving collisions between the limbs of any NPC in a scalable manner.

I was considering this complete suggestion, but I am thinking of making a main plaza that involves a potentially great number of characters (NPCs + players). If someone else knows of any neat (and cleaner) tricks I could pull to achieve both the (1) and (2) specifications, that’d be nice.

Dude :sob:
image

It would work for disabling collisions between NPC models, you just have to make another collision group for them. The logic is the same

1 Like

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