void HandleHealth() { if (vitals.GetCurrentHealth() <= 0) { Cursor.lockState = CursorLockMode.None; SceneManager.LoadScene(4); } }
private void Start() { canJump = true; Physics.IgnoreLayerCollision(8, 9); rb = GetComponent <Rigidbody>(); regSpeed = movementSpeed; vitals = GetComponent <Vitals>(); playerHealth = vitals.GetCurrentHealth(); _dodgeTime = dodgeTime; bobSpeed = anim.speed; healthAmount.text = "(" + playerHealth.ToString() + ")"; healthBar.fillAmount = 1; }
void Update() { if (myVitals.GetCurrentHealth() > 0) { switch (states) { case ai_states.idle: stateIdle(); break; case ai_states.move: stateMove(); break; case ai_states.combat: stateCombat(); break; case ai_states.Investigate: StateInvestigate(); break; default: break; } } else { //DIE anim.SetBool("move", false); if (GetComponent <BoxCollider>() != null) { Destroy(GetComponent <BoxCollider>()); } Quaternion deathRot = Quaternion.Euler(-90, myTransform.rotation.eulerAngles.y, myTransform.rotation.eulerAngles.z); if (myTransform.rotation != deathRot) { myTransform.rotation = deathRot; } } }