private void UseClosestItem() { if (ClosestItem != null) { Debug.Log("Item exists"); ClosestItem.Use(); } }
void Update() { if (_state.State != StateType.In_Game || isUsing || !Input.GetKeyDown(KeyCode.Mouse0)) { return; } RaycastHit hit; if (Physics.Raycast(Camera.position, Camera.forward, out hit, MaxDistance)) { InteractibleItem item = hit.collider.gameObject.GetComponent <InteractibleItem>(); if (item != null) { Debug.Log("Picked up item: " + item.name); item.Use(); } } }