Camera problem

Hi there,
Im still new in Unity,
I have a problem with a camera.
It is quite simple, im making a FPS and when I slide I would like the camera to move down a bit and to get back his position when the input is released. I dont know ho to access my Main Camera.

Please help me
THX

It sounds like all you need to know if how to access the main camera. You can do that by using “Camera.main”. Was that all you need?

Usually FPS characters have the camera childed to them - you could change the camera’s transform.localPosition to shift its relative position. You can access the main camera with Camera.main, like this (script attached to any scene object - usually the character):

var offset: float = 0.1;
private var camTransf: Transform;
private var pos0: Vector3;

function Start(){
  camTransf = Camera.main.transform;
  pos0 = camTransf.localPosition;
}

function Update(){
  var pos = pos0;
  pos.y -= offset*Input.GetAxis("Vertical");
  camTransf.localPosition = pos;
}

In this example, the main camera transform is saved in camTransf, and the camera is shifted down by an offset distance when the forward control is pressed, and is shifted up when going backwards.