void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.CompareTag("Block")) { var speed = lastVelocity.magnitude; var direction = Vector2.Reflect(lastVelocity.normalized, other.contacts[0].normal); rb.velocity = direction * bulletSpeed; } else if (other.gameObject.CompareTag(tag = "Player")) { playerHit = true; //game.EndGame(); FindObjectOfType <GameManager>().EndGame(); } else if (other.gameObject.CompareTag(tag = "Target")) { targetHit = true; var speed = lastVelocity.magnitude; var direction = Vector2.Reflect(lastVelocity.normalized, other.contacts[0].normal); rb.velocity = direction * bulletSpeed; target = other.gameObject.GetComponent <TargetScript>(); target.Dead(); } }