public bool Interact(Transform _transform, Vector3 position) { if (playerMove.isGhost) { return(false); } //attempt to trigger the things in range we clicked on if (PlayerManager.LocalPlayerScript.IsInReach(position)) { //check the actual transform for an input trigger and if there is non, check the parent InputTrigger inputTrigger = _transform.GetComponentInParent <InputTrigger>(); if (inputTrigger) { if (objectBehaviour.visibleState) { inputTrigger.Trigger(position); return(true); } //Allow interact with cupboards we are inside of! ClosetControl cCtrl = inputTrigger.GetComponent <ClosetControl>(); if (cCtrl && cCtrl.transform.position == PlayerManager.LocalPlayerScript.transform.position) { inputTrigger.Trigger(position); return(true); } return(false); } } //if we are holding onto an item like a gun attempt to shoot it if we were not in range to trigger anything return(InteractHands()); }
public bool Interact(Transform _transform, Vector3 position) { if (playerMove.isGhost) { return(false); } //attempt to trigger the things in range we clicked on if (PlayerManager.LocalPlayerScript.IsInReach(position)) { //check the actual transform for an input trigger and if there is non, check the parent InputTrigger inputTrigger = _transform.GetComponentInParent <InputTrigger>(); if (inputTrigger) { if (objectBehaviour.visibleState) { inputTrigger.Trigger(position); //FIXME currently input controller only uses the first InputTrigger found on an object /////// some objects have more then 1 input trigger, like players for example /////// below is a solution that should be removed when InputController is refactored /////// to support multiple InputTriggers on the target object if (inputTrigger.gameObject.layer == 8) { //This is a player. Attempt to use the player based inputTrigger P2PInteractions playerInteractions = inputTrigger.gameObject.GetComponent <P2PInteractions>(); if (playerInteractions != null) { playerInteractions.Trigger(position); } } return(true); } //Allow interact with cupboards we are inside of! ClosetControl cCtrl = inputTrigger.GetComponent <ClosetControl>(); if (cCtrl && cCtrl.transform.position == PlayerManager.LocalPlayerScript.transform.position) { inputTrigger.Trigger(position); return(true); } return(false); } } //if we are holding onto an item like a gun attempt to shoot it if we were not in range to trigger anything return(InteractHands()); }