Ejemplo n.º 1
0
 public void TakeDamage(float damage)
 {
     if (currentState != PLAYER_STATE.DEAD)
     {
         movement.StopAllCoroutines();
         movement.edgeRecovery = false;
         StartCoroutine(movement.RecoveryTimer(4));
         currHealth -= damage;
         CheckHP(currHealth);
         if (currHealth <= 0)            //If out of hp, kill player
         {
             KillPlayer();
         }
     }
 }
Ejemplo n.º 2
0
    void OnCollisionEnter(Collision collider)
    {
        if (collider.gameObject.tag == "Player")
        {
            physicMovement = collider.gameObject.GetComponent <PhysicMovement1>();
            physicMovement.StopAllCoroutines();
            physicMovement.edgeRecovery = false;
            physicMovement.RecoveryTimer(3);
            rb = collider.gameObject.GetComponent <Rigidbody>();
            anim.SetTrigger("Bump");
            Vector3 dir = collider.contacts[0].point - transform.position;
            dir = dir.normalized;

            rb.AddForce(dir * force);
            playSound();
        }
    }