void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Eugenio") { foreach (ContactPoint2D contact in collision.contacts) { float centerDistances = contact.point.x - transform.position.x; collision.gameObject.rigidbody2D.AddForce(new Vector2(100f * centerDistances, 0)); } } else if (collision.gameObject.tag == "Star") { Destroy(collision.gameObject); controlClass.AddScore(20); controlClass.ChangeUpdatedScore(); //Set it as true Debug.Log("STAR"); starBonus = true; } else if (collision.gameObject.tag == "QMark") { Destroy(collision.gameObject); // 0 - Big size // 1 - Small size int size = Random.Range(0, 2); if (size == 0) { scale[0] *= 2; } else { scale[0] /= 2; } transform.localScale = new Vector3(scale[0], scale[1], scale[2]); Debug.Log("QMARK"); qmBonus = true; } else if (collision.gameObject.tag == "Up") { Destroy(collision.gameObject); controlClass.SetSpeed(15.0f); Debug.Log("UP"); upBonus = true; } else if (collision.gameObject.tag == "Down") { Destroy(collision.gameObject); controlClass.SetSpeed(5.0f); Debug.Log("DOWN"); downBonus = true; } else if (collision.gameObject.tag == "Aim") { Destroy(collision.gameObject); Vector3 gunPos = transform.position; gunPos.y -= powerGunPrefab.gameObject.renderer.bounds.extents.y; powerGunPrefab = Instantiate(powerGunPrefab, gunPos, transform.rotation) as GameObject; powerGunActivated = true; } }