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

A game object can only be in one layer. The layer needs to be in the range [0...31] UnityEngine.GameObject:set_layer(Int32) WeaponLayer:Start() (at Assets/Scripts/WeaponLayer.cs:18)

$
0
0
using System.Collections; using System.Collections.Generic; using UnityEngine; public class WeaponLayer : MonoBehaviour { public string npcTag; public LayerMask npcLayer; public LayerMask playerLayer; // Use this for initialization void Start () { if (gameObject.transform.root.gameObject.tag == npcTag) { gameObject.layer = npcLayer; } else { gameObject.layer = playerLayer; } } } I have this simple script to change between layers, which works fine, but I get this error. My layers exist and I just choose which one to have for npcLayer and which one for playerLayer. If my script sees that it has the npcTag it just changes to the npcLayer, anything else it chooses the playerLayer. What am I missing?

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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