How to keep camera at certain level while moving

How to keep camera at certain level while moving and rotating camera up and down?

If I move position with transform.translate(movex, 0, movez) the height level changes also.

Should I use transform.position.x and …y but then I need to calculate the x and y with sine and cosine??

Up and down is all the y-axis. X will move it sideways, z will move it forward and back.

Hmmm… I wonder if using Vector 3 and variables on the camera would get it to move… (not sarcastic)

Here is what I’m getting at:

using UnityEngine;
using System.Collections;

public class InsertNameHere : MonoBehaviour {
	public float speed = -6f;
        Vector3 movement; 

void Awake (){
}

void update (){
float up = Input.GetKey (KeyCode.Space);
float LAndR = Input.GetAxis ("Horizontal");
float FAndB = Input.GetAxis ("Vertical");

Cameramovement (LAndR, up, FAndB);
}
    
void Cameramovement (float LAndR, float up, float FAndB){
movement.Set (LAndR, up, FAndB);

movement = movement.normalized * speed * Time.deltaTime;

playerRigidbody.MovePosition (transform.position + movement);}

This is all in C#, and I am not 100% positive that this will fix your problem, but try it.
Just copy and paste this into a new C# script, and change “InsertNameHere” To your script’s name. Remember, no spaces on the script name!

Hope this helped!!!