private void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.GetComponent <Rigidbody2D>() != null) { if (col.name != "Dummy") { shake.CamShake(); float direction = 0f; float angularVel = 0f; if (player.transform.position.x < col.gameObject.transform.position.x) { direction = 2f; angularVel = -100f; } else { direction = -2f; angularVel = 100f; } col.gameObject.GetComponent <Rigidbody2D>().velocity = new Vector3(direction, 2f, 0f); col.gameObject.GetComponent <Rigidbody2D>().angularVelocity = angularVel; } } }
void OnTriggerEnter2D(Collider2D other) { shake.CamShake(); if (other.CompareTag("Boss")) { other.GetComponent <Enemy>().health -= damage; Destroy(gameObject); } }