Orthographic (Birds-Eye View/Top-Down) Player Follow Script w/ Smoothing

To put it simply, I’m very much hoping someone can quickly write up a fairly simple follow script (with dampening). I’ve opened approximately forty seven links from the Google machine and downloaded/copy-pasted more examples than I can count of follow scripts, and they either fell under one of two issues. Either A, they required the attached object to have a camera, which it can’t. Either that, or B, they followed the object on the wrong axis and whenever I’d try to correct said axis it’d just flip out.

Currently I’ve got my main camera (as well as some other depth cameras) parented under an empty object. Meanwhile, I have my player object which is somewhere else. Due to various more complicated reasons, I can’t simply child the camera object to the player object.

I should also mention this is done via an orthographic camera pointed down at the play field (in a birds-eye/top-down view), so the object should only follow the player on the X and Z axis. It also needs dampening, or at least some sort of smoothing to target.

Below, are some example scripts that might be useful to anyone who finds this thread but is looking for something simpler; and why they won’t work in this situation.

var dampTime : float = 0.3; //offset from the viewport center to fix damping
private var velocity = Vector3.zero;
var target : Transform;
 
function Update() {
    if(target) {
        var point : Vector3 = camera.WorldToViewportPoint(target.position);
        var delta : Vector3 = target.position -
                    camera.ViewportToWorldPoint(Vector3(0.5, 0.5, point.z));
        var destination : Vector3 = transform.position + delta;
        transform.position = Vector3.SmoothDamp(transform.position, destination, 
                                                velocity, dampTime);
    }
}

// http://answers.unity3d.com/questions/29183/2d-camera-smooth-follow.html - Source

The above code will not work as it adjusts a camera entity, rather than an object. Considering we’re dealing with multiple cameras, we need it to move the parent object which this script will not allow. Otherwise, this works perfectly fine.

var cameraSpring = 3.0;
var target : Transform;

function Update () {
    var wantedPos = target.position;

    wantedPos.z = transform.position.z;
    transform.position = Vector3.Lerp (transform.position, wantedPos, Time.deltaTime * cameraSpring);

}
// http://forum.unity3d.com/threads/215179-Need-some-help-with-some-2D-Camera-following - Source

This code works perfectly, except in that it only follows on the Z axis. Not to mention, it doesn’t have proper dampening.
.

As always, I’m forever grateful Unity Answers. I realize this isn’t a place to have everything done for you, but I can’t get anywhere on my own for this one. Thank you.

This might be what you are looking for:

using UnityEngine;
using System.Collections;

public class OrthoSmoothFollow : MonoBehaviour {

	public Transform target;
	public float smoothTime = 0.3f;

	private Vector3 velocity = Vector3.zero;

	void Update () {
		Vector3 goalPos = target.position;
		goalPos.y = transform.position.y;
		transform.position = Vector3.SmoothDamp (transform.position, goalPos, ref velocity, smoothTime);
	}
}

This script would run better if you use FixedUpdate instead of Update()