Thirdperson camera follow ball

Hi,
I followed the ballgame tutorial on unity and a tutorial from John Mac :Unity Third Person Control.
I’m trying to combine these tutorials. with a camera like Zelda on a rotating ball.
This is not working yet, when I hit play the camera gets wobbly.
I Think it is in the line :transform.position = Vector3.Lerp (transform.position, targetPosition, Time.deltaTime * smooth );
I know people asked many questions about the rolling ball, but can someone please help me further with this one.

using UnityEngine;

public class Camera_ball_follow : MonoBehaviour {

	// Use this for initialization
	#region Variables (private)

	[SerializeField]
	private float distanceAway;
	[SerializeField]
	private float distanceUp;
	[SerializeField]
	private float smooth;
	[SerializeField]
	private Transform follow;
	private Vector3 targetPosition;

	#endregion

	void Start () 
	{
		follow = GameObject.FindWithTag("EmptyHelper").transform;	
	
	
	}
	
	// Update is called once per frame
	void Update () 
	{
		
	}
	void OnDrawGizmos ()
	{
	
	}

	void LateUpdate ()
	{ //setting the target position to be the correct offset from the ball
		targetPosition = follow.position + Vector3.up * distanceUp - follow.forward * distanceAway;
		Debug.DrawRay (follow.position, Vector3.up * distanceUp, Color.red);
		Debug.DrawRay (follow.position, -1f * Vector3.forward * distanceAway, Color.blue);
		Debug.DrawLine (follow.position, targetPosition, Color.magenta);
		//making a smooth transition between its current position and the position it wants to be in

		transform.position = Vector3.Lerp (transform.position, targetPosition, Time.deltaTime * smooth );

		//makes sure the camera looks the right way
		transform.LookAt (follow);
	}
}

No replies.