// Use this for initialization void Start() { /* Following code provided by Martin "quill18" Glaude */ Cursor.lockState = CursorLockMode.Locked; cc = GetComponent <CharacterController>(); /* End code provided by Martin "quill18" Glaude */ statManager = GetComponent <StatisticsManager>(); carryManager = GetComponentInChildren <CarryManager>(); toolManager = GetComponentInChildren <PlayerToolManager>(); moveSpeed = statManager.MoveSpeed; }
//Awake is always called before any Start functions void Awake() { //Check if instance already exists if (instance == null) { //if not, set instance to this instance = this; } //If instance already exists and it's not this: else if (instance != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } //Sets this to not be destroyed when reloading scene DontDestroyOnLoad(gameObject); carryManager = GameObject.Find("CarryManager").GetComponent <CarryManager>(); InitializeTools(); }