- Home /
What does this mean ?
when i'm making script to enable doorTween onTriggerEnter i always got this message.
var doorTween : DoorTween; //DoorTween is a script
var doorStates : DoorState;
enum DoorState {Open,Closed}
function Open(){
doorTween.enabled = true;
doorStates = DoorState.closed;
}
Assets/Standard Assets/Scripts/General Scripts/Door.js(3,17): BCE0018: The name 'DoorTween' does not denote a valid type ('not found').
what does that mean ? and also sometimes i got this message
ArgumentException: You are not allowed to call get_gameObject when declaring a variable.
Move it to the line after without a variable declaration.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
UnityEngine.Component.GetComponent (System.String type) (at C:/BuildAgent/work/842f9557127e852/Runtime/ExportGenerated/Editor/UnityEngineComponent.cs:126)
Door..ctor () (at Assets/Standard Assets/Scripts/General Scripts/Door.js:3)
try declaring var doorTween as public; that should show the variable in the inspector so you can put the DoorTween script in. i take it that the code you posted starts with line 17?
no, this script is shorter line 17 was : doorTween.Open(); and on DoorTween(Script) has function OpenDoor(){ iTween.rotateTo(gameObject, {"y":76.8653, "time":3.0}); }
Answer by Bunny83 · Nov 15, 2011 at 04:17 PM
You have your "Door script" in "Standard Assets". That means it's compiled before all regular scripts (all scripts outside of Standard Assets or plugins). So scripts in Standard Assets can't use "normal" scripts. You should either move your Door script out of Standard Assets or put the other script into Standard Assets.
For more information on that subject see the manual (compilation order)
Your second exception happens because you can't call a function when you initialize a script variable. Shortcut properties like ".transform" or ".renderer" are just function calls behind the scenes (they use GetComponent). You have to declare your variables without a value and assign the value in Start (That's actually exactly what the error message suggests):
// UnityScript
// THIS WON'T WORK: Here you will get the error
var myVariable : Renderer = renderer;
// That's how you should do it:
var myVariable : Renderer;
function Start()
{
myVariable = renderer;
}
when i change it. i've got another problem NullReferenceException: Object reference not set to an instance of an object FPSInputController.Update () (at Assets/S$$anonymous$$IPPER'S/Scripts/FPSInputController.js:43) on line 43, i assign it's doorScript enumeration, on editor i've assigned the doorscript to Door. but when i'm play it, doorScript become none(door) i also move FPSInputController to another folder, if i move it to default place (Standart Asset) i've got the same message : Assets/Standard Assets/Character Controllers/Sources/Scripts/FPSInputController.js(6,25): BCE0018: The name 'Door' does not denote a valid type ('not found').