Unity LayerMask Explained: 1<<12 & Bitwise Operations
The line of code you provided initializes a private variable called "layerMask" and assigns it a value of "1<<12". \n\nIn Unity, a "LayerMask" is used to define which layers should be affected by certain operations or calculations, like raycasting or collision detection. \n\nThe expression "1<<12" is a bitwise left shift operation, which means shifting the binary representation of the number 1 twelve positions to the left. In this case, it is effectively setting the 13th bit to 1 and all other bits to 0. \n\nThis means that the "layerMask" is set to only include objects that belong to the 13th layer (counting from layer 0 as the first layer).
原文地址: https://www.cveoy.top/t/topic/qeN2 著作权归作者所有。请勿转载和采集!