transform.localPosition drives me crazy...

if (Input.GetAxis("Mouse X"))
{

var translationX = Input.GetAxis("Mouse X")* Time.deltaTime*moveSpeed;
if (  (transform.localPosition.x+translationX)<3.5 (transform.localPosition.x+translationX)>-3.5)
  {
   var heighttransform =translationX/2;
   transform.localPosition +=    Vector3(translationX,heighttransform,0);
		 
			Debug.Log(transform.localPosition.x);
		}

I try to move my 3rd-person-cam by mouse from left to th right and back. This works fine.
but I want this bloody thing also to go up and down.
You move the camera to the left and it shall move downwards too. When you move the camera back to the right, it shall go up, till it is above the player and when you move it more to the right it shall go down again.I ve tried so much but i cant figure out how it will work.
Does some one can give me a hint?

if you want it to go left and right…why is the last value of that vector3 equal to 0?

vector 3s go (x,z,y) for some reason

the last value is forward and backward :wink:

if (Input.GetAxis("Mouse Y"))
{
var translationZ = Input.GetAxis("Mouse Y")*Time.deltaTime*moveSpeed;
        if ( (transform.localPosition.z+translationZ)<3.5 (transform.localPosition.z+translationZ)>-1)
		{
		 transform.localPosition += Vector3(0,0,translationZ);
			
		}

No, they go X, Y, Z. In Unity, Y is up.

–Eric

Has no one an idea???