Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        // Player Health Check

        if (other.gameObject.tag.Contains("Enemy_") || other.gameObject.tag == "Death_Trigger")
        {
            //get other game object, enemy data component
            _playSoundBehaviour.PlaySound("Player_Hit");
            _player_damage.SetPlayerDamage(other.gameObject.tag);
            Destroy(other.gameObject);
        }

        // Player Score Check

        if (other.gameObject.tag.Contains("Object_")) // checks if the other.gameobject.tag have Object_ .
        {
            _player_score.SetPlayerScore(other.gameObject.tag);
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "Ground")
        {
            _player_movement.PlayerGrounded = true;
        }
    }
Exemplo n.º 2
0
 void Update()
 {
     KeyCheck();
     if (JumpKey)
     {
         if (_grounded)
         {
             _playSoundBehaviour.PlaySound("Player_Jump");
             _rigidbody2D.AddForce(Vector2.up * _jumpPower);
             _grounded = false;
         }
     }
     if (DownKey)
     {
         _rigidbody2D.AddForce(Vector2.down * _jumpPower / 2);
     }
 }