Script Error Problem (help with script)

I am using this script, to detect collision from camera. (attached to player, ray pointed at camera)

var player : GameObject;


function Update () {

	var ray : Ray = Ray(player, player.transform.position - transform.position);
	var hit : RaycastHit;
	
	if(Physics.Raycast(ray, hit)){
		Camera.main.transform.position = ray.GetPoint(hit.distance-1);
		
	}
}

I keep getting this error.

Error

Assets/Scripts/Camera/CameraCollision.js(7,28): BCE0024: The type 'UnityEngine.Ray' does not have a visible constructor that matches the argument list '(UnityEngine.GameObject, UnityEngine.Vector3)'.

Error At

var ray : Ray = Ray(player, player.transform.position - transform.position);

How do I get this to work properly finally…

Try that

var ray : Ray = new Ray(player.transform.position, player.transform.position - transform.position);

‘player’ is of type GameObject, and there is no Ray constructor that takes a GameObject and a Vector3 as arguments.

It’s probably the position of the player object’s transform that you want to submit as the first argument.

so I need to put the script on the player and send a ray from him at the camera GameObject?

or by chance do you have any code example if thats incorrect idea or something XD ?

Were you able to fix the compiler error you asked about?

I have it working but It will detect Extremely far away and it is jittery.

How would I use RaycastHit.distance to make it only cast only so far ?

and how would I make them smooth transitions instead of jittery ?

If could do like small example scripts please would be helpful so i know how to use them.

Here is the code currently.

var Camera : GameObject;

function Update () {
	
	var ray : Ray = Ray(transform.position, Camera.transform.position - transform.position);
	var hit : RaycastHit;
	
	if(Physics.Raycast(ray, hit)){
		Camera.transform.position = ray.GetPoint(hit.distance-1);
		
	}else{
		Camera.transform.localPosition = Vector3(0.0, 3.3, -5.4);
		}
	}

Fixed and I now have Jittering Fixed all works but I need to figure out how to get the ray to only track a certain distance. How do i do that?

ceilingObject.transform.position = Vector3(ceilingLoadPos);

I am getting this same error. I have declared and labeled my gameobject and vector3.

:.?