- Home /
BCE0044 expecting ), found 'script' and BCE0043 unexpected token )
I made a simple moving script when these 2 errors came up and it said they were on (6,78) and (6,102) but both end up in the middle of words and when i try to remove ) it come up with more errors can any one please help me? This is the script-
var walkAcceleration : float = 5;
var cameraObject : GameObject;
function Update ()
{
transform.rotation = Quaternion.Euler(cameraObject.GetComponent(look script).currentYRotation);
rigidbody.AddReletiveForce(Input.GetAxis("horizontel") * walkAcceleration, 0, Input.GetAxis("vertical")* walkAcceleration);
}
Answer by bompi88 · Jul 30, 2013 at 07:45 PM
It's inside your GetComponent. Wrap the name of your script inside "", like:
cameraObject.GetComponent("MyScript")
Im gonna have to oppose this (and is not what his problem is anyways).
Directly from documentation: It is better to use GetComponent with a Type ins$$anonymous$$d of a string for performance reasons. Sometimes you might not be able to get to the type however, for example when trying to access a C# script from Javascript. In that case you can simply access the component by name ins$$anonymous$$d of type.
it now come up with UnityException: Input Axis horizontel is not setup. To change the input settings use: Edit -> Project Settings -> Input player movement.Update () (at Assets/player movement.js:7)
You see, exception even tells you EVERYTHING you need to fix. Try it.
Answer: It is Horizontal not horizontel. Capitalization is important aswell.
Hint: vertical will also be a problem.
Answer by Lovrenc · Jul 30, 2013 at 07:46 PM
I dont want to give you the answer directly, but here is your problem:
GetComponent(look script)
Aditional hint, focus on script name.
is it the space because capitals are all right or do i have to change the name in my project floder
Yes, spaces are not alowed in a name. Compiler cannot know what goes together if there is a space.
some convetions:
lookScript
look_script
I see youre using camel notation in variables names. So i suggest you rename your script to lookScript.
now come up with referenced script on this behavior is missing and it also come up with InvalidCastException: Cannot cast from source type to destination type. playermovement.Update () (at Assets/playermovement.js:6)
This is because you are trying to use Quaternion.Euler() which takes in a Vector3 or 3 floats, and you only give it something called "currentYRotatation" which is probably not a Vector3
Referenced script is missing...
You dont have a script you are trying to access... You need to go back to basics man.