- Home /
Question by
deadpenguin · Nov 21, 2013 at 04:06 PM ·
variablecalling
Calling a variable from another script at an instance.
I am trying to import a variable form another script at the instance it is called.
function Update () {
characterMovement = GetComponent(CharacterMotor).currentMovementOffset;
// transform.position = new Vector3(objectFollow.transform.position.x,objectFollow.transform.position.y + yOffset,objectFollow.transform.position.z + zOffset);
MoveX();
}
function MoveX() {
if (Mathf.Abs(objectFollow.transform.position.x - transform.position.x) >= maxBufferX)
transform.position.x += characterMovement.x;
if (Mathf.Abs(objectFollow.transform.position.x - transform.position.x) >= maxBufferX + .5)
transform.position.x += .5;
}
this is the error im getting too: NullReferenceException: Object reference not set to an instance of an object
Comment
Please see potential causes and fixes in this question/answer.
Your answer
![](https://koobas.hobune.stream/wayback/20220613122419im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Variable Question. [Simple] & [JS] 1 Answer
GUI.DrawTexture Error & Static Variables!! 2 Answers