How can stuff not be working while it works in another script....

Hello everyone!

It looks like I just made one dumb mistake but heres the code that stands in 2 c# scripts but is working in only 1 script:

 if(Input.GetMouseButtonUp(0)){
		Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
		Collider2D hitCollider = Physics2D.OverlapPoint(mousePos);
		
		if(hitCollider){
			if(hitCollider.name.Contains("menu")){
				print ("I have just clicked a part of the menu!");
			}
			print (hitCollider.name);
		}
		else{
			print ("not detected any colliders :(");
		}
	}

The result in the first script is that it prints the name of the clicked collider whilst in the other script the result is that it prints “not detected any collider”.

Note: maybe it is important to know that these two scripts are in two different unity projects.
And I didnt forget to add a 2d collider! :stuck_out_tongue:

thank you for even reading my question.
Any help is appreciated!

It may be to do with the Z positioning of the colliders. Make sure the colliders in both your project have the same z position just to check its not that. Also your code will not work with 3d colliders because your using the Phsics2D stuff in your script.