// Update is called once per frame void Update() { if (controller == null) { Debug.Log("Controller not inizialised"); return; } gripButtonDown = controller.GetPressDown(gripButton); gripButtonUp = controller.GetPressUp(gripButton); gripButtonPressed = controller.GetPress(gripButton); triggerButtonDown = controller.GetPressDown(triggerButton); triggerButtonUp = controller.GetPressUp(triggerButton); triggerButtonPressed = controller.GetPress(triggerButton); if (gripButtonDown) // wenn durch den trigger bereits collided { float minDistance = float.MaxValue; float distance; foreach (InteractableItem i in objectsHoveringOver) { distance = (i.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; closestItem = i; } } interactingItem = closestItem; if (interactingItem) { if (interactingItem.IsInteraction()) { interactingItem.EndInteraction(this); } interactingItem.BeginInteraction(this); } } if (gripButtonUp && interactingItem != null) { interactingItem.EndInteraction(this); } }