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

NullReferenceException: Object reference not set to an instance of an object InputEnabler.Enable () (at Assets/scripts/InputEnabler.cs:26) Inventory.Update () (at Assets/scripts/Inventory.cs:30)

$
0
0
using UnityEngine; using System.Collections; using UnityStandardAssets.Characters.FirstPerson; public class InputEnabler : MonoBehaviour { static FirstPersonController FPSChar; // Use this for initialization void Start () { FPSChar = GameObject.FindObjectOfType(); Disable(); } public static void Disable() // disabling cursor and enabling movement { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; FPSChar.enabled = true; } public static void Enable() // enabling cursor and movement { Cursor.visible = true; Cursor.lockState = CursorLockMode.None; FPSChar.enabled = false; } } using UnityEngine; using System.Collections; public class Inventory : MonoBehaviour { public GameObject inventory; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if(inventory.activeSelf) { if(Input.GetKeyDown(KeyCode.I)) //Disable Inventory inventory.SetActive(false); InputEnabler.Disable(); } else { if(Input.GetKeyDown(KeyCode.I)) { //Emable Inventory inventory.SetActive(true); InputEnabler.Enable(); } } } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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