Deprecate CanCollide, add new PhysicsMode property

People constantly complain about not being able to disable CSG physics, so I thought of a good solution that solves this problem as well as many others.

The Problem(s):

  • CSG Physics cannot reliably be disabled. CanCollide being false still affects performance due to .Touched listeners.
  • A ton of parts in a small area can cause a tremendous performance impact, even if CanCollide is false.
  • CSG does not have bounding box physics as an option.

The Solution:
Deprecate the CanCollide property by removing it from the Properties Explorer, as well as removing most functionality from the property. (More on this below)

Make a PhysicsMode property for BaseParts and UnionOperations. This property is an Enumerator type property, and contains the following values:

  • Normal: Normal physics are applied.
  • NoCollide: Object does not register physics collisions, but still fires .Touched events. Exactly like CanCollide = false.*
  • NoPhysics: Object does not register physics collisions, and does not fire .Touched events. Gravity and other forces still apply.
  • NoGravity: Normal physics are applied, and still fires .Touched events. Gravity and other forces do not apply.
  • NoPhysicsAndGravity: Object does not register physics collisions, and does not fire .Touched events. Gravity and other forces do not apply.
  • BoundingBox: Object is forced to use bounding box collision, and still fires .Touched events. Gravity and other forces still apply.
  • Note: CanCollide should still be scriptable to prevent breaking existing places! Simply wrap true/false to Normal/NoCollide respectively.

So yeah, that’s my idea. Hope it makes sense as I typed this on the fly. Criticism welcome.

Seems interesting, but why do you want gravity when you aren’t applying collisions or .Touched events?

because if the option isn’t there someone will complain about that too

because if the option isn’t there someone will complain about that too[/quote]

To be honest, I think two more boolean properties should be added instead, with CanCollide.

boolean IgnoreCollisionEvents -- This will ignore .Touched events, when touching a part with a connection or when it's connected to itself.
boolean IgnoreGravity -- This will ignore the force of gravity entirely. Other forces still apply, making it easier for users to make parts which float.
1 Like

I would agreewith FiniteReality, it would make it easier just adding the 2 booleans.

These seems like a really cool modal. I support it.

[quote]
The Solution:
Deprecate the CanCollide property by removing it from the Properties Explorer, as well as removing most functionality from the property. [/quote]

Not sure if removing most of CanCollide’s functionality would be a solution. There’s a lot of games out there that rely on this kind of stuff. Please don’t advocate to remove any of CanCollide’s functionality, only to add other properties to new booleans.

Bloaaaaat

[quote]
The Solution:
Deprecate the CanCollide property by removing it from the Properties Explorer, as well as removing most functionality from the property. [/quote]

Not sure if removing most of CanCollide’s functionality would be a solution. There’s a lot of games out there that rely on this kind of stuff. Please don’t advocate to remove any of CanCollide’s functionality, only to add other properties to new booleans.[/quote]

Please read the rest of the post to understand the reasoning behind this.

I’d prefer a physics masking system so we could have some parts collide with some other parts but not these parts, but these parts can collide with those parts and these players but not that player or his parts.

I think the best API would be something like

[code]
Enum CollisionMode
[0] NoCollisions - does not collide or fire touched events
[1] CollisionsEnabled - collides and fires touched events
[2] EventsOnly - does not collide but does fire touched events
[3] BoundingBoxCollisions - like CollisionsEnabled but the part will use its bounding box to calculate collisions

String BasePart.PhysicsMask
Defaults to “Global”. The part will use this masks’s physics settings.

String Humanoid.PhysicsMask
Defaults to “Global”. The humanoid will use this masks’s physics settings

PhysicsService:SetPhysicsMode(String mask1, String mask2, PhysicsMode mode)
Determines how certain parts of mask1 will interact with parts of mask2 and vice versa

PhysicsService:InheritPhysicsModes(String mask1, String mask2)
Allows mask1 to inherit mask2’s physics modes. If mask2 is nil it will remove mask1’s inheritance. Everything inherits Global by default.

Workspace:FindPartOnRay(Ray ray, Object ignoreDescendantsInstance, String physicsMask=“Global”)
The ray would behave as a member of that physics mask and pass through parts which have the NoCollisions setting[/code]

Then you could do things like

[code]union.PhysicsMask = “BoxUnions”

PhysicsService:SetPhysicsMode(“BoxUnions”, “Global”, “BoundingBoxCollisions”)[/code]

[code]union.PhysicsMask = “NonCollidingUnions”

PhysicsService:SetPhysicsMode(“NonCollidingUnions”, “Global”, “NoCollisions”)[/code]

[code]humanoid.PhysicsMask = “Humanoids”
brick.PhysicsMask = “Debris”
floor.PhysicsMask = “Floor”

PhysicsService:SetPhysicsMode(“Humanoids”, “Floor”, “CollisionsEnabled”) – humanoids can walk on the floor (this is default behavior so this line isn’t actually needed)
PhysicsService:SetPhysicsMode(“Floor”, “Debris”, “NoCollisions”) – the debris will fall right through the floor without firing any events[/code]

[code]humanoid.PhysicsMask = “Humanoids”
wall.PhysicsMask = “Wall”

– we don’t need to set Humanoids-Wall to CollisionEnabled because that is the default setting
PhysicsService:SetPhysicsMode(“Wall”, “BulletRay”, “NoCollisions”)

hit = workspace:FindPartOnRay(ray, nil, “BulletRay”) – the ray is using the BulletRay mask. BulletRay is set to NoCollisions for Wall, so the ray will ignore the wall.[/code]
Or something more complex

[code]alphaDebris.PhysicsMask = “AlphaDebris”
betaDebris.PhysicsMask = “BetaDebris”
floor.PhysicsMask = “Floor”
humanoid.PhysicsMask = “Humanoids”

PhysicsService:SetPhysicsMode(“BetaDebris”, “Floor”, “NoCollisions”) - The beta debris will fall through the floor
PhysicsService:SetPhysicsMode(“Humanoids”, “AlphaDebris”, “EventsOnly”) - The alpha debris will not collide with humanoids but it will fire events
PhysicsService:SetPhysicsMode(“BulletRay”, “Humanoids”, “NoCollisions”) - Bullets will go through humanoids
PhysicsService:SetPhysicsMode(“BulletRay”, “BetaDebris”, “NoCollisions”) - Bullets will go through beta debris

alphaDebris.Touched:connect(function(hit) - We set Humanoids-AlphaDebris to EventsOnly. The humanoid will walk through the parts but still fire the events
humanoid.Health = 0
end)

hit = workspace:FindPartOnRay(ray, ignore, “BulletRay”) - This ray will use BulletRay settings and ignore parts under the Humanoids and BetaDebris mask

if hit.PhysicsMask == “AlphaDebris” then
hit:Destroy()
end[/code]

[code]union.PhysicsMask = “Unions”

PhysicsService:SetPhysicsMode(“Unions”, “Global”, “BoundingBoxCollisions”) - this must come first or else it would overwrite the Unions-Raycasts setting
PhysicsService:SetPhysicsMode(“Unions”, “Raycasts”, “CollisionsEnabled”) - enables accurate collisions for raycasts

– now you can perform raycasts with the Raycasts mask and they will use accurate collisions for parts with the Unions mask[/code]

[code]humanoid1.PhysicsMode = “Humanoids”
humanoid2.PhysicsMode = “Humanoids”

PhysicsService:SetPhysicsMode(“Humanoids”, “Humanoids”, “EventsOnly”)[/code]

@Ethan: hehehehe ROBLOX to the rescue:



They used the same example too.

Wouldn’t it be much more convenient to keep CanCollide and Anchored, and simply add a “BoxCollision” boolean property to unions, rather than having to change all BaseParts and break all scripts?