How can I move the camera in game?

I want to be able to move the camera while playing the game, and I can’t figure out how to do that. Here’s the player script:

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {

public float speed;

private Rigidbody rb;

void Start ()
{
	rb = GetComponent<Rigidbody>();
}

void FixedUpdate ()
{
	float moveHorizontal = Input.GetAxis ("Horizontal");
	float moveVertical = Input.GetAxis ("Vertical");
	
	Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
	
	rb.AddForce (movement * speed);
}

}

And here’s the camera script:

using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour {

public GameObject player;

private Vector3 offset;

void Start ()
{
	offset = transform.position - player.transform.position;
}

void LateUpdate ()
{
	transform.position = player.transform.position + offset;
}

}

Am I supposed to add something to either script or not?

I think I know what you mean. You want the camera to chase the player along the level? So it looks at the player but doesn’t follow their exact position and kind of floats towards them? If so I’d suggest you use the Vector3.MoveTowards method to calculate your cameras new position in your updates.

eg:

Vector3 moveDelta = Vector3.MoveTowards(cameraPosition, playerPosition, maxMoveSpeed);

if you adjust the maxMoveSpeed, so that when the camera is close to the player it only moves slowly, but speeds up as they get further away, your camera will move in a floating lagging way. Obviously use LookAt on the camera too so it actually watches the player.

If you are wanting to stay a fixed Z position from the player then make sure you overwrite the players Z co-ord in their location Vector to stop the camera actually moving into them.

HTH