- Home /
NullReferenceException Problem
I am getting an object reference not set issue, and I am a newbie coder. Joystick refers to a script named joystick.js. Any help would be great. Here is the code: #pragma strict
var Stick: Joystick;
function Update ()
{
transform.Translate(Vector2.up * Time.deltaTime * Stick.position.x);
}
Answer by Dave-Carlile · Jan 24, 2013 at 09:05 PM
You've declared a variable name Stick, but have you assigned anything to it? You simplest way to do that is by dragging the joystick.js script to the Stick property in the editor.
If I do this, nothing happens. I can click the concentric circle button, and select joystick.js, but then the field does not change, simply saying "None (Joystick).... I am still stuck. Sorry for what I'm missing.
Never $$anonymous$$ind. I assigned it to the joystick PREFAB, rather than script, fixing this. Your solution helped. Thanks.
Your answer
![](https://koobas.hobune.stream/wayback/20220613091531im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Object Pool object reference is null? 1 Answer
Need Help With a NullReference Exception 2 Answers
Accessing other GameObjects Script Variables 2 Answers