I just started learning unity and now I just started learning UnityScript API’s.
In this below script I am able to do everything I am doing for the object and its working properly but in below the code I am trying to access function from another script and it shows me an error message.
“NullReferenceException: Object reference not set to an instance of an object
CubeBehaviour_01.Update () (at Assets/Scripts/CubeBehaviour_01.js:22)”
Here is the code
CubeBehavious.JS
var CubeSpeed = 1;
var accessVariable : GameObject;
function Update () {
this.transform.Translate(0,0,Time.deltaTime*CubeSpeed,Space.Self);
//Rotate the Object -> Cube.
this.transform.Rotate(0,0,1);
accessVariable.transform.Translate(0,0,Time.deltaTime*CubeSpeed,Space.Self);
var accessScript = GetComponent(SecondScript);
accessScript.newFunction("Hello");
}
SecondScript.js
function Update () {
}
function newFunction (s : String)
{
var newSpeed = 10;
print("Hello World " + newSpeed);
}
this newFunction is the function I am accessing.
Sorry if this is a very basic question. I am just a beginner . Thank you for your time.