User-defined Unity Layers & Raycasts - Ignored by VRChat?

Hey everyone!

I’ve been working on a game world for VRC, but just hit a really confusing problem. I was following the documentation here on layers: Unity Layers in VRChat | VRChat Creation .

I created 3 new layers for my world, on layers 23-25. Enemies, Floor, PlayerItems

I’m using a raycast on specific layers, using LayerMask.GetMask

if (Physics.Raycast(spawnPointTransform.position, spawnPointTransform.TransformDirection(Vector3.up), out var hit,
                    maxDistance: MAX_DISTANCE, layerMask:LayerMask.GetMask("Floor", "Enemies", "Environment")))

And this works perfectly in editor. But when I do a “Build & Test”, objects in my new layers don’t get returned from the raycast. It hits anything in the ‘Environment’ layer though. So… what the heck? It’s causing a ton of game-breaking bugs. :(

Any help would be very much appreciated.

Ok, well I finally found out the problem here. Layers CANNOT be referred to by name! So replacing

LayerMask.GetMask("Floor", "Enemies", "Environment")

with

int layerMask = 1 << 11 | 1 << 23 | 1 << 25;
...
Physics.Raycast( ... layerMask:layerMask)

Solved the issue.

This was so immensely frustrating. Please update the documentation around this. I lost 4 hours to this. I eventually found my answer here: Notion