5.0 Roll-A-Ball Help!

I am trying to get the camera to follow the ball.

In the tutorial video, it says “First we need to create a reference to the player game object by dragging the player game object into the player slot.” However in unity 5.0 there is no “player slot”, the inspector is different than that in the tutorial video.

So how do I refer to player with my camera?

Sorry I am new. Thanks for the help!

Here is my error if I try to run it anyways:
Assets/Scripts/CameraController.cs(19,45): error CS0019: Operator +' cannot be applied to operands of type UnityEngine.Transform’ and `UnityEngine.Vector3’

which part and which second of the videotutorial are you at? This would help a lot in answering this question.

In the unity inspector you select a gameobject in the scene view. If the gameobject has a script attached to it, and if the script contains some public variables, you should see in the inspector some input fields with the names of those variables. If that is not happening, something in the script is wrong. Go back in the tutorial to where the script is shown and cvompare it carefully to your script → error.

Right, I’m fairly certain your referring to video 4 of the tutorial.

Once you have written your script and saved it go back into EDIT mode.

Now when you click on the camera (you must have the script attached to the camera) look at the inspector panel. Look for the section that relates to the script.

There you will see a little panel with the word Player written next to it. Drag your player object (the sphere) into that little panel. That little panel/slot is what the tutor is referring to.

:slight_smile:

43296-p1.png

I apologize in advance that I’m not familiar with the tutorial you’re referencing, and can’t specifically address your concerns but your dilemma sounds quite familiar.

The script appears to be C#, rather than Javascript, so your “Player” variable needs to be a public variable.

public GameObject Player;

Additionally, your error of

“Assets/Scripts/CameraController.cs(19,45): error CS0019: Operator +’ cannot be applied to operands of type UnityEngine.Transform’ and `UnityEngine.Vector3”

suggests that you are performing an operation such as

Player.transform += Vector3.forward;

when, in that situation, it would instead need to read

Player.transform.position += Vector3.forward;

I had exactly the same issue.
I found that there was another error in my script and that it was not related to the

public GameObject player;

line. When I corrected the other error and saved the script, the player tag appeared in the inspector for the camera controller. Looking at your script, I see that there is a } missing at the end. Should end with:

transform.position = player.transform.position + offset;
 }
}

Also, your offset line is missing part of the code. Should be:

offset = transform.position - player.transform.position;

Hope that helps.