attempting to use the function SetTarget from the AbstractTargetFollower script. I keep getting the error “Null Reference Exception: Object Reference not set to an instance of an Object”
Here’s the simple script I am using
using UnityEngine;
using System.Collections;
using UnityStandardAssets.Cameras;
public class CamTarget : MonoBehaviour {
public AbstractTargetFollower ATF;
// Use this for initialization
void Start () {
}
void OnMouseDown()
{
ATF.SetTarget (gameObject.transform);
}
}
I attach this to a cube - put a few cubes in a scene, and click on them.
I’ve tried a few variations too - using send message, also explicitly getting the transform component of the cube. no luck.
Any help would be appreciated.
Thanks
[code ][/code ] tags when you paste code into the forums please, really helps with the readability and puts in line numbers… and errors have line numbers in them, please include them 
have you dragged the AbstractTargetFollower component into the ATF slot in the inspector?
if it’s on the same gameobject as the one the above script is on you might try
ATF = GetComponent<AbstractCameraController>();
in the start function
Thanks for explaining the code tags. Here is where i’m at.
using UnityEngine;
using System.Collections;
using UnityStandardAssets.Cameras;
public class CamTarget : MonoBehaviour {
public AbstractTargetFollower ATF;
private Transform goref;
// Use this for initialization
void Start () {
ATF = GetComponent<AbstractTargetFollower> ();
goref = GetComponent<Transform> ();
}
void OnMouseDown()
{
ATF.SetTarget (goref);
}
}
the error is on line 21 of the code above.
AbstractTargetFollower.cs is a script that (apparently) cannot be added to a gameobject because it is abstract (which I am not used to working with). So I did not have any luck dragging placing it on a scene element or dragging it in the ATF slot of inspector. I did change it from private to public - so it shows up in the inspector.
frustrating - what I’m trying to do is access the SetTarget function in the script via another script attached to each scene element that can be a camera target.
Thanks.