relative to camera?

I have this code:

var moveSpeed = 5.0;

function Update () {
        // Calculate speed
        var speed = moveSpeed;
if (Input.GetKey(KeyCode.LeftShift)) {
        speed *= 2;
}
        // Move the GameObject
transform.Translate(Vector3.forward * Input.GetAxis("Vertical") * Time.deltaTime * speed);
        
transform.Translate(Vector3.right * Input.GetAxis("Horizontal") * Time.deltaTime * speed);
}

How would i make it so that the object moves relative to which ever camera is active (I have a few that i switch between in the scene)?

Declare a public variable in your script that references the currently used camera’s transform (let’s call it activeCam, of type Transform). Make sure you update it when you switch cameras. Then all you have to do is use activeCam.forward and activeCam.right instead Vector3.forward and Vector3.right.