void OnCollisionEnter2D(Collision2D col) { // Hit the Racket? if (col.gameObject.name == "racket") { if (!sticky) { // Calculate hit Factor float x = HitFactor(transform.position, col.transform.position, col.collider.bounds.size.x); // Calculate direction, set length to 1 Vector2 dir = new Vector2(x + col.gameObject.GetComponent <Rigidbody2D>().velocity.x / 300, 1).normalized; // Set Velocity with dir * speed rb2D.velocity = dir * speed; } else // sticky { rb2D.velocity = new Vector2(); transform.parent = col.gameObject.transform; transform.localPosition = new Vector3(transform.localPosition.x, 7.0f, transform.localPosition.z); rb2D.simulated = false; } racket.GetComponent <Racket>().woveDown(); } // Hit the bottom else if (col.gameObject.name == "border_bottom") { Destroy(gameObject); Time.timeScale = 0; pause = Camera.main.GetComponent <Pause>(); pause.BroadcastMessage("GameOver"); } // Hit the Block else if (block = col.gameObject.GetComponent <Block>()) { block.DestroyBlock(); } }