Altering character movement disables camera follow script

Hi - I’m controlling a characters animator movements based on an external sensor value (‘energy’):
functionFixedUpdate ()
{animator.SetFloat(“Run”, sprint);}
functionRuning () {
if (Timer.energy >= 400f)
{sprint = 0.2;}
else
{sprint = 0.0;}

Seeing as I have disabled the regular code “v = Input.GetAxis(“Vertical”);”
The camera follow script I had been using no longer works:
targetPosition = follow.position + Vector3.up * distanceUp + follow.up * distanceAway;
transform.position = Vector3.Lerp(transform.position, targetPosition, Time.deltaTime * smooth);

Can anyone recommend a workaround ?

So this camera is behind the object and must follow it at a certain height and distance?

Hi - the camera can be placed at any location in the scene and it follows the specified target by panning but it doesn’t move or physically follow…ie it just follows by panning like a cctv camera. I’ve attached the script that I was using…but now no longer works.

1971100–127727–MindBotCamera.cs (1 KB)

then rather you should change the transforms rotation instead of position. This is straight from the docs :

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
       public Transform target;
       void Update()
       {
              Vector3 relativePos = target.position - transform.position;
              Quaternion rotation = Quaternion.LookRotation(relativePos);
              transform.rotation = rotation;
       }
}

Thanks I managed to get it working