Random Camera Jitter

Hi. I’m working on a script where the camera follows the character smoothly. When I test it out, the y-axis follows smoothly, but when I test out the movement on the x-axis, it seams to jitter when the character is near ether edges of the screen. Heres some code:

var target : Transform;

// Height damping var:
var heightDamping = 2.0;
// x-axis position var:
var xPosDamping = 1.0;

function LateUpdate () {
	// Damp the height
	var currentHeight = Mathf.Lerp (transform.position.y, target.position.y, heightDamping * Time.deltaTime);
	
	// Damp the x-axis movement
	var currentXPos = Mathf.Lerp (transform.position.x, target.position.x, xPosDamping * Time.deltaTime);
	
	// Set the position of the camera
	transform.position = Vector3(currentXPos, currentHeight, transform.position.z);
}

Thanks for your help,
-GameDude

Unity is included with a SmoothFollow which applies to the camera which will achieve what you seem to want. Just modify to your need.

Import CharacterController. Will be at Standard Assets > Character Controller > Scripts > SmoothFollow