/* * FUNCTION: Called when player bumps into an obstacle side-ways */ void OnCollisionEnter(Collision collision) { if (hInGameScript.isEnergyZero()) { return; } else if (bSidesColliderFlag == true) { hPlayerFrontColliderScript.deactivateFrontCollider(); //pause front collision detection till stumble is processed hControllerScript.processStumble(); //handle the collision } }
void Update() { // Debug.Log("***** " + getCurrentWalkSpeed()); if (hInGameScript.isGamePaused() == true) { return; } if (getCurrentWalkSpeed() < 1) { hInGameScript.pauseGame(); } if (hInGameScript.isEnergyZero()) { //Debug.Log("*** 4 energy is at 0 - Update ControllerScript ***"); if (DeathScene()) { return; } } if (invincible && Time.time - invincibilityStartTime > invincibilityDuration) { CancelInvoke("invincibleFlash"); playerRenderer.enabled = true; if (PersistentManagerScript.Instance.obstacles) { tFrontCollider.GetComponent <BoxCollider>().enabled = true; tPlayerSidesCollider.GetComponent <BoxCollider>().enabled = true; } invincible = false; } getClicks(); //get taps/clicks for pause menu etc. if (bControlsEnabled) { SwipeMovementControl(); } //running by pressing alternating keys if (Input.GetKeyDown("n")) { if (mPressedLast) { mPressedLast = false; nPressedLast = true; lastKeyPress = Time.time; //Debug.Log(lastKeyPress); } } //m if (Input.GetKeyDown("m")) { if (nPressedLast) { nPressedLast = false; mPressedLast = true; lastKeyPress = Time.time; //Debug.Log(lastKeyPress); } } }