Camera follow script

Hey guys, I am stuck getting a proper camera working, I have a game similar to Mario Galaxy (players controls an object to move around a sphere). The camera should show the player from a top down perspective (no need to allow players to rotate the camera).

I tried using the smooth follow script from the Unity assets folder, however that led to the following problem.
Whenever the player moved to the other side of the sphere the camera did not rotate properly with the character.

I need a camera which always stays above the player and rotates accordingly. This worked perfectly when making the camera a child of the player, however I need some finetuning for the camera therefore that is no option anymore, so I need to achieve exactly the same result via code.

Any help appriciated.

try this -

using UnityEngine;
using System.Collections;

public class FollowPlayerCSharp : MonoBehaviour
{
	public Transform target;
	public float distance;
	

	void Update()
	{
		if (!target)
		{
			// Search for object with Player tag
			var go = GameObject.FindWithTag("Player");
			// Check we found an object with the player tag
			if (go)
			// Set the target to the object we found
			target = go.transform;
		}

		if (target)
			transform.position =new Vector3(target.position.x, target.position.y+25, target.position.z - distance);
	}
}

:slight_smile: