private void OnCollisionEnter2D(Collision2D collision) { Vector2 _vec2 = Vector2.zero; body.velocity = _vec2; _vec2 = transform.position - collision.transform.position; hitStrength = hitStrength * collision.gameObject.GetComponent <playerData>().playerSize; if (data.GetComponent <playerData>().GetPlayerPos() == Vector2.zero) { body.AddForce(_vec2 * hitStrength, ForceMode2D.Impulse); float f = Mathf.Acos(Vector2.Dot(shootVel.normalized, _vec2.normalized)) * Mathf.Rad2Deg; transform.Rotate(0, 0, f); shootVel = body.velocity; transform.DOPunchScale(new Vector3(Vector2.ClampMagnitude(_vec2, 0.1f).x, Vector2.ClampMagnitude(_vec2, 0.1f).y, 0), 1.0f, 5, 1); music.playMusic("bounce"); } }