Exemple #1
0
    void OnCollisionEnter(Collision collision)
    {
        // Colisão com camada "chao".
        if (collision.gameObject.layer == 9)
        {
            _canJump = true;
            _playerCentral.SetHitStun(false);
        }

        // Colisão com espinhos.
        if (collision.gameObject.tag == "Enemy")
        {
            Vector3 dir = collision.transform.position - transform.position;
            dir = -dir.normalized;
            if (dir.y < 0.3)
            {
                dir.y = 0.3f;
            }
            if (dir.x == 0 && dir.z == 0)
            {
                dir.x = 0.5f;
            }
            _rb.velocity = dir * _forceHit;
        }
    }
Exemple #2
0
    public void Damage(int damage)
    {
        if (!_playerCentral.GetHitStun())
        {
            _hp -= damage;
            _playerCentral.SetHitStun(true);
        }

        if (_hp <= 0)
        {
            InstaKill();
        }
    }