Null Reference Exception and not sure where I went wrong? Script and two screenshots attached
//Here is my script. I get the NullReference exception: object reference not set to the instance of the object. The error seems to be in the Start section
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class crow_receive : MonoBehaviour { Animator crowac; public OSC osc;
// Use this for initialization
void Start () {
crowac = GetComponent<Animator>();
osc.SetAddressHandler("/CubeXYZ", OnSurprise);
}
// Update is called once per frame
void Update () {
}
void OnSurprise(OscMessage message) {
float x = message.GetFloat (0);
if (x > 2) {
crowac.SetTrigger ("MakeRed");
}
}
}
screen-shot-2017-07-09-at-15224-pm.png
(217.6 kB)
screen-shot-2017-07-09-at-15408-pm.png
(59.4 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612125834im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
NullReferenceException 5 Answers
how to control instances velocity? 0 Answers