2d collision detecting simultaneous collisions.

I’ve created a simple 2d tennis game. The game detects collision from the ball. If the ball hits the paddle it plays a sound and determines the direction that the ball will be sent to the other side. When a ball hits both the upper boundary and the paddle at the same time no collision is detected. Any insight on how I can get the collider to work?

I included some code and video. In the video the first hit does not fire off the “if ((col.gameObject.tag == “paddle”” when it hits the paddle and the wall at the same time.

void OnCollisionEnter2D(Collision2D col ) {
		foreach(ContactPoint2D contact in col.contacts){
			Debug.Log("col");
		// Hit the left Racket?
			if ((col.gameObject.tag == "paddle" && noman == false) {
			audio.Play();
			if (noscore == false){
			player1Score++;
				noscore = true;
			}

The problem is that you are using “col.gameObject.tag” instead of “contact”.

The ball hits the paddle and wall, so it gets a collision message with 2 contacts. You loop through both contacts, but check col.gameObject.tag for both of them rather than checking the tag of the contact point.

What you want is if (contact.gameObject.tag

Also, you have 2 opening brackets after the if, but only one closing bracket.