private void Update() { if (activeController != null && !gm.isPaused) { activeController.Tick(); } if (Input.GetKeyDown(KeyCode.Mouse4)) { Debug.Log("Attempting to Possess"); Vector3 rayOrigin = activeController.cam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0)); RaycastHit hit; // Check if there's an interactable target in range. if (Physics.Raycast(rayOrigin, activeController.cam.transform.forward, out hit, 5.0f)) { // Declare Target; GameObject targetHit = hit.transform.gameObject; Debug.Log(targetHit.name); if (targetHit.GetComponentInParent <FPS_Controller>() != null) { activeController.Eject(); activeController = targetHit.GetComponentInParent <FPS_Controller>().Possess(this); } } } if (Input.GetKeyDown(KeyCode.Mouse3)) { activeController.Eject(); activeController = defaultController.Possess(this); } }
private void Start() { if (activeController != null) { activeController.Possess(this); } else { activeController = defaultController.Possess(this); } }
protected override bool ProcessInteraction(Actor source, Controller instigator) { if (isLocked) { FPS_Pawn FPP = (FPS_Pawn)source; if (FPP) { if (FPP.hasKey) { isLocked = false; DoorOpen.Play(); return(false); } } if (_ms) { _ms.SetGameSmallText(true, popupHint, hintPopupTime); } return(false); } HorrorGame hg = FindObjectOfType <HorrorGame>(); if (!hg) { LOG_ERROR("No object in scene with HorrorGame attached. Can not ask to end game."); return(true); } hg.EndGame(true); FPS_Controller FPC = (FPS_Controller)instigator; if (FPC) { FPC.UnPossesPawn(FPC.GetPossesedPawn()); FPC.allowPausing = false; } return(true); }
protected virtual void Die() { if (!_controller) { return; } FPS_Controller FPC = (FPS_Controller)_controller; if (FPC) { FPC.PawnHasDied(); } else if (_controller) { _controller.UnPossesPawn(this); } //Do something to the camera image effect handDominant.Unequip(); handSubordinate.Unequip(); _rb.freezeRotation = false; }