// disables or enables the player based on entered bool void DisablePlayer(bool pSetDisable) { /** Tell teleport script you are in a keypad before the script is called to be disabled */ if (!_teleportScript) { _teleportScript = _player.GetComponent <TeleportScript>(); } _teleportScript.isInKeypad = pSetDisable; foreach (MonoBehaviour script in _player.GetComponents <MonoBehaviour>()) { script.enabled = !pSetDisable; } _characterBehaviour = _player.GetComponent <CharacterBehaviour>(); _characterControllerScheme = _player.GetComponent <CharacterControllerScheme>(); if (pSetDisable) { _characterBehaviour.SetPhysicsColider(false); _characterControllerScheme.StopMovement(); } if (!pSetDisable) { _characterBehaviour.SetPhysicsColider(true); } }
// Use this for initialization void Start() { // make sure there is a teleport point in the scene if (!_teleportPoint) { Debug.Log("No Teleport Point Prefab added to Player."); _teleportPoint = GameObject.Find("TeleportPoint"); } // make sure there is a Player Shadow in the scene if (!_fakePlayer) { Debug.Log("No player shadow prefab added to scene."); _fakePlayer = GameObject.Find("PlayerShadow"); } // make sure there is a teleport radius in the scene if (!_radius) { Debug.Log("No teleport radius added to scene"); _radius = GameObject.Find("TeleportRadius"); } /** Check for OnPlayerHUD */ if (!_onPlayerHUD) { _onPlayerHUD = GetComponent <OnPlayerHUD>(); } if (!_mainCam) { _mainCam = Camera.main.GetComponent <CameraController>(); } if (!_charBehaviourScript) { _charBehaviourScript = gameObject.GetComponent <CharacterControllerScheme>(); } if (!_characterBehaviour) { _characterBehaviour = GetComponent <CharacterBehaviour>(); } if (!_teleportPointRenderer) { _fakePlayer.SetActive(true); _teleportPointRenderer = GetComponentInChildren <MeshRenderer>(); _fakePlayer.SetActive(false); } if (!_teleportParticleSystem) { _fakePlayer.SetActive(true); _teleportParticleSystem = GetComponentInChildren <ParticleSystem>(); _fakePlayer.SetActive(false); } _rb = gameObject.GetComponent <Rigidbody>(); _anim = gameObject.GetComponent <Animator>(); _mainCamera = Camera.main; // initializing variables _isCooled = true; _isActive = false; }