void Update() { if (EventSystem.current.IsPointerOverGameObject()) { return; // Благодарение на този ред не позволяваме на играчът да отчита кликовете върху инвентара // като дестинация, към която да се запъти. } Vector3 hitPoint = GetMouseHit().point; if (Input.GetMouseButton(0)) { movement.MoveToDestination(hitPoint); } if (Input.GetMouseButtonDown(1)) { StartCoroutine(combat.FireAtMouse(GetMouseHit())); //Useful if player has bow as a weapon. } if (Input.GetKey(KeyCode.LeftShift)) { movement.StopMoving(); movement.LookAt(hitPoint); if (Input.GetMouseButtonDown(0)) { combat.onAttack(); } } if (Input.GetMouseButtonDown(0)) { // Try to get component Interactable from the hit object. interactable = GetMouseHit().collider.GetComponent <Interactable>(); // If interactable is not null, set object as new focus and start trying interaction. if (interactable != null) { oldInteractable = interactable; movement.SetFocus(interactable); Debug.Log("FOKUSIRAHME " + interactable.name); if (interactionInProcess == false) { interactionInProcess = true; interactable.StartCoroutine("TryInteraction"); } } // If interactable is null, remove focus and stop trying interaction. else { movement.RemoveFocus(); if (oldInteractable != null) { interactionInProcess = false; oldInteractable.StopCoroutine("TryInteraction"); } } } }