// private void OnEnable(){ // InputController.GetInputManager().Player.Interact.performed += CheckSwitchPlayer; // } // private void OnDisable(){ // InputController.GetInputManager().Player.Interact.performed -= CheckSwitchPlayer; // } private void CheckSwitchPlayer(InputAction.CallbackContext ctx) { MouseInputUtil.RayCastMousePosition(hit => { GameObject hitObj = hit.transform.gameObject; if (hitObj.GetComponent <FriendController>() != null && hitObj.GetComponent <FriendController>().settings.active) { SetCurrentPlayer(hitObj); } }); }
private void CheckInteraction(InputAction.CallbackContext ctx) { MouseInputUtil.RayCastMousePosition(hit => { Interactable interactable = hit.collider.transform.GetComponent <Interactable>(); if (interactable == null) { interactable = hit.collider.transform.GetComponentInParent <Interactable>(); } if (interactable != null) { Interaction interaction = new Interaction(InteractionType.PLAYER, currentPlayer); interactable.Interact(interaction); } }); }