Roll-a-ball tutorial does not work.

I have gone through this tutorial from start to finish, following the instructions exactly. Though the ball moves around, the camera will not follow it, and the camera coordinates in the inspector do not seem to respond to the CameraController script at all.

I am using Unity version 2018.1.0f2

alt text

This is the CameraController script I am using (edited in VS 2010):

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraController : MonoBehaviour

    public GameObject player;

    private Vector3 offset;

    // Use this for initialization
    void Start()
        //player = GameObject.Find("Player");
        offset = transform.position - player.transform.position;

    // Update is called once per frame
    void LateUpdate()
        //player = GameObject.Find("Player");
        transform.position = player.transform.position + offset;

I have tried some suggested fixes, including the inclusion of the
player = GameObject.Find(“Player”);

but nothing works. I would be very grateful if somebody explain how to make this work, as I have tried every suggestion or alternative code snippet I could find in these forums and elsewhere.

The instructions must either be incomplete, or incompatible with the latest version. It would be nice if Unity could look at this.


The issue that you are having is that you did not add the Player GameObject to the CameraController script. To do that, go to the Unity editor and select the “Main Camera” object. In the Inspector, look for the Camera Controller Script. If you look at the Camera Controller script, under Player, you will see that there is no object referenced in the Player game object slot. All you have to do now is left-click and drag the Player GameObject from the Hierarchy, and drop it on the Player slot in the Camera Controller script.
Hope this solves your issue.