- Home /
BCE0005 Unknown identifier issue
Got this script from a tutorial. Did everything he did in the video. Running Mac OSX Leppoard. Any thoughts??
Answer by robertbu · Jun 07, 2013 at 04:14 AM
You should go back and carefully review the tutorial vs. your code. Your code likely should be something like:
#pragma strict
var forwardSpeed : float = 500;
var turnSpeed : float = 3.0;
function Start () {
}
function Update () {
var forwardMovementAmount = Input.GetAxis("Vertical") * forwardSpeed;
var turnAmount = Input.GetAxis("Horizontal") * turnSpeed;
transform.Rotate(0,turnAmount,0);
rigidbody.AddRelativeForce(forwardMovementAmount, 0,0);
}
The main issue with your code was one of scope. You declare 'forwardSpeed' and 'turnSpeed' inside of Start(). That means that they will only 'live' inside Start() once Start() is done, the variables no longer exist. Look at my rewrite above. The variables are declared outside of Start().
Note that in Javascript, variables are public by default. This means that if you want to change these values after the script has been attached to a game object, you need to do it in the Inspector. Chances in the script will be ignored after the script is attached.
Your answer
Follow this Question
Related Questions
List in JS, Unknown indentifier 3 Answers
Need some help with my Gravity Gun, New to Scripting. 1 Answer
Why am I getting this error repeatedly? 2 Answers
BCE0049 error with networking script 0 Answers
IndexOutOfRangeExeption - Array index is out of range 2 Answers