Skip to content

feat: sdk collision layer main player#8865

Draft
pravusjif wants to merge 1 commit into
devfrom
feat/collision-layer-main-player
Draft

feat: sdk collision layer main player#8865
pravusjif wants to merge 1 commit into
devfrom
feat/collision-layer-main-player

Conversation

@pravusjif
Copy link
Copy Markdown
Member

@pravusjif pravusjif commented May 22, 2026

Adds the CL_MAIN_PLAYER collider layer (replaces the unused CL_RESERVED2) and unifies how Raycast and TriggerArea treat ColliderLayer masks for the local player avatar.

What changed

  • New layer CL_MAIN_PLAYER (value 8) — targets the local player avatar specifically.
  • Additive avatar semantics — the main player is tagged with both CL_PLAYER and CL_MAIN_PLAYER; remote avatars carry only CL_PLAYER.
  • Unified main-player qualification rule — both Raycast and TriggerArea now use the same constant PLAYER_QUALIFYING_BITS = CL_PLAYER | CL_MAIN_PLAYER. CL_PHYSICS, CL_POINTER, CL_CUSTOM*, and CL_NONE no longer hit / fire on the local player.
  • MeshCollider / GltfContainer — masks containing CL_PLAYER or CL_MAIN_PLAYER (without CL_PHYSICS) now route to a new dedicated Unity layer SDKAvatarHit: raycast- and trigger-detectable, but the player capsule walks through (previously the collider was silently disabled). Mixing in CL_PHYSICS keeps the mesh solid against the player.
  • TriggerArea optimisation — a CL_MAIN_PLAYER-only trigger now skips remote-avatar overlaps inside the MonoBehaviour via the existing TargetTransform early-out.
  • Unity layer rename AllAvatarsSDKAvatarTriggerArea — the layer slot (18) is unchanged, only the name changes. The old name was misleading (no avatars actually live on that layer; it hosts the avatar-targeting TriggerArea collider). Pairs cleanly with the existing SDKEntityTriggerArea name. C# constant renamed PhysicsLayers.ALL_AVATARSPhysicsLayers.SDK_AVATAR_TRIGGER_AREA.

Behaviour comparison

BEFORE

Mask Raycast hits main player TriggerArea fires for main player
CL_PLAYER yes yes
CL_PHYSICS yes no
CL_POINTER alone yes no
CL_CUSTOM* alone yes no
CL_NONE yes no

The two systems disagreed on every mask except CL_PLAYER. (CL_MAIN_PLAYER did not exist.)

AFTER

Mask Raycast hits main player TriggerArea fires for main player
CL_PLAYER yes yes
CL_MAIN_PLAYER yes yes
CL_PLAYER | CL_MAIN_PLAYER yes yes
CL_PHYSICS no no
CL_POINTER alone no no
CL_CUSTOM* alone no no
CL_NONE no no

The two systems now agree on every mask.

Migration note

Scenes that previously relied on CL_PHYSICS raycasts to detect the local player must now OR CL_MAIN_PLAYER (or CL_PLAYER) into their mask. Walls-and-floors physics checks that do not target the player are unchanged.

Related PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature a new feature sdk

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants