Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Error: a game object can only be in one layer. The layer needs to be in the range [0...31]

$
0
0
I got a error where it says: A game object can only be in one layer. The layer needs to be in the range [0...31]. Here is my code: string remoteLayerName = "RemotePlayer"; [SerializeField] string dontDrawLayerName = "DontDraw"; [SerializeField] GameObject playerGraphics; [SerializeField] GameObject playerUIPrefab; [HideInInspector] public GameObject playerUIInstance; void Start () { // Disable components that should only be // active on the player that we control if (!isLocalPlayer) { DisableComponents(); AssignRemoteLayer(); } else { // Disable player graphics for local player SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDrawLayerName)); // Create PlayerUI playerUIInstance = Instantiate(playerUIPrefab); playerUIInstance.name = playerUIPrefab.name; } GetComponent().Setup(); } void SetLayerRecursively (GameObject obj, int newLayer) { obj.layer = newLayer; foreach (Transform child in obj.transform) { SetLayerRecursively(child.gameObject, newLayer); } } If anyone knows how to fix this i would want to know :)

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>