Hey I know there’s been a couple of related posts here but I don’t see how I am having the same issues (not confusing static/instance, not missing a particular function call). My game is actually working fine but wanted to see how can I go about resolving this issue? Maybe just where is the problem ?
Thank you!
Once again the message is:
NullReferenceException: Object reference not set to an instance of an object
CameraRaycaster.Update () (at Assets/Camera & UI/CameraRaycaster.cs:46)
public delegate void OnLayerChange(); // Declare new delegate type
public event OnLayerChange layerChangeObservers; // instantiate an observer pool.
void Start() //TODO Awake?
{
viewCamera = Camera.main;
// layerChangeObservers += LayerChangeHandler; // add to set of handling functions
// layerChangeObservers(); // call all of the observers/subscribers/delegates
}
void Update()
{
// Look for and return priority layer hit
foreach (Layer layer in layerPriorities)
{
var hit = RaycastForLayer(layer);
if (hit.HasValue)
{
raycastHit = hit.Value;
if(layerHit != layer){
layerHit = layer;
layerChangeObservers(); //problem here
}
return;
}
}
// Otherwise return background hit
raycastHit.distance = distanceToBackground;
layerHit = Layer.RaycastEndStop;
}