- Home /
Error: an exposed variable in a JavaScript is not a member of that script
Hello, I am new to Unity. I am following Script Tutorial. There are several scripts attached to Spotlight. One script, Follow, will turn Spotlight towards where Main Camera looks at. The other script, Switch, will detact user typing space bar and it will then direct the spotlight onto a cube.
There is an exposed variable, target : Transform, in Follow. It is set to Main Camera through the GUI interface (Inspector). In Switch, it tries to reassign target of Follow to the cube:
var switchToTarget : Transform; function Update () { if (Input.GetButtonDown("Jump")) { var other : Follow; other = GetComponent("Follow"); other.taget = switchToTarget; } }
Unity reports a compile error:
'target' is not a member of 'Follow'.
If the code for Switch is exactly as in the tutorial,
var switchToTarget : Transform; function Update () { if (Input.GetButtonDown("Jump")) { GetComponent(Follow).taget = switchToTarget; } }
Unity reports an error "Field 'Follow.target' not found." at run time.
I am stuck. Thanks for any help!
Answer by loopyllama · Mar 26, 2011 at 07:45 AM
try "target" instead of "taget". looks like a simple typo. I bet the error really says "taget is not a member of Follow"...