S1L5 : A Simple DIY Follow Camera || NullReferenceException: Object reference

I’m still getting the error: NullReferenceException: Object reference not set to an instance of an object
CameraArm.Start () (at Assets/CameraArm.cs:12)

Could you please help me?

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

public class CameraArm : MonoBehaviour {

GameObject player;

// Use this for initialization
void Start () {

// Update is called once per frame
void Update () {

Edit: Added the code

1 Like

Have you set the tag on the Player GameObject to Player?

Scrub that, I can see that you haven’t in your first screenshot. Because you haven’t set the tag to Player on the Player GameObject, the player variable on line 11 is not populated because the method returns nothing.

Also, it’s quite difficult to read code via the screenshots, you can paste your code into the forum and it handles it nicely. Screenshots are of course very useful for error messages and views of the Unity editor.

Hope this helps :slight_smile:

See also;

1 Like

Thank you Rob

Now the problem is fixed. I better re-check the unity course.

1 Like

You’re very welcome Emrah, it’s an easy to miss item. Glad you can move forwards with the course again :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms