public class Enemy : MonoBehaviour
{
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Player") {
collision.gameObject.GetComponent<player>().RecountHp(-1);
collision.gameObject.GetComponent<Rigidbody2D>().AddForce(transform.up * 14f, ForceMode2D.Impulse);
}
}
}
private void OnTriggerEnter2D(Collider2D other)
{
if(other.GetComponent<PlayerController>() != null)
{
...
}
}