RaycastHit problem

hi guys,

i’m newbie for coding and here. i got a problem when using Physics.Raycast(); when i try to use something like Physics.Raycast(ray, out hit); it’s always error said invalid argument or can not convert RaycastHit to float. i tried to copy some code like this to my script but still same error(event example from unity raycast example the script that i copy can work with their own project, but not mine) here’s my simply script for raycasting

void Update () {
		
		if(Input.GetMouseButtonDown(0))
		{
			RaycastHit hit = new RaycastHit();
			Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
			
			if(Physics.Raycast(ray, out hit)) //error here
			{
				print ("hit");
			}		
		}		
	
	}

i tried both
RaycastHit hit; and
RaycastHit hit = new RaycastHit(); but both fail, i notice that i can’t even access to any RaycastHit member (like hit.point …)

please help me fix this, i tried this all 2 days :frowning:
thank for attention

I can fixed this problem right now, the error from my bad to create class name same as RaycastHit struct so i rename class name then all work well :stuck_out_tongue: , thank so much robhuhn.