I'm having some problems with getting a vector3 variable from another script.
In Update(), I'm running this next script through once, using a bool checking if it has just been done.
This works fine when I debug it. The problem comes when I want to get it in another script.
First I define this.
Grid is the name of the script where I want to get the vector3 from.
Then, in the Start() i do the following:
And lastly, I'm using it like this:
I've also tried this, but to no luck: krudt.transform.position = new Vector3(krudtScript.krudtPosition);
I'm getting this error: NullReferenceException: Object reference not set to an instance of an object
That's simply because you implicitly use:
So you search for this script on the gameobject this script is attached to and not on the other where it actually is.