couple troubles.

I have a scipt that moves the camera to collision point and back too original position, however I cant get it too move too the camPos empty that I have on scene which represents the original distance from the player. I cant get it too work right for some reason, anyone have an idea?

var Cam : GameObject;

var smoothTime = 0.45;

var dis : float = 3;





private var velocity = Vector3.zero;





function LateUpdate () {

	

	var camPos : GameObject;

	camPos = GameObject.Find("CameraPosition");

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

	var hit : RaycastHit;

	

	if(Physics.Raycast(ray, hit, dis)){

		Cam.transform.position = ray.GetPoint(hit.distance-1);

		

	}else{



		Cam.transform.Position = Vector3.SmoothDamp(Cam.transform.localPosition, camPos.transform.Position, velocity, smoothTime);

	}

}



//   hit.transform.tag != "Rebounder"

I also have a rotation script that rotates the empty with the camera parented to it but I want it to limit the max rotation so that I cant flip the axis all the way around, this is third person camera, but for example on a first person camera you can normally only look straight up at max, or down.

My script atm without the restriction is

function Update(){

LookAround();

}



function LookAround() {

var y = Input.GetAxis ("Mouse Y");

transform.Rotate (-y, 0, 0);

}

How do i get that restriction ?

why are you mixing positions and localpositions?

“I have a scipt that moves the camera to collision point and back too original position,”
I can’t really understand this. Do you want a smooth animation? Do you want it to recalculate to see if it’s hitting a point each frame, or do you want it, when it detects a hit, to remember that point then move to it and back. You can’t get it to work - what’s going wrong with it when you try to?