- Home /
Problem is not reproducible or outdated
Problems with javascript
I followed an outdated tutorial on how to create an AI the tutorial version of the unity is the 3.5.0 and mine is 3.5.6 so here is the tutorial's error line :
#pragma strict
var distHeroi : Vector3;
var velocidadeTranlate: float;
var distanciaMinima: float;
var normX: float;
var normZ: float;
function Start ()
{
distanciaMinima = 10;
}
function Update ()
{
velocidadeTranlate = 6 * Time.deltaTime;
distHeroi = corpo.posicaoHeroi - transform.position;
normX = distHeroi.x;
normZ = distHeroi.z;
if(normX < 0)
normX = -normX;
if(normZ < 0)
normZ = -normZ;
print(normX+" - "+normZ);
if(normX == 0)
transform.Translate(velocidadeTranlate,0,0);
else
transform.Translate(-velocidadeTranlate,0,0);
if(distHeroi.z > 0)
transform.Translate(0,0,velocidadeTranlate);
else
transform.Translate(0,0,-velocidadeTranlate);
}
function OnCollisionEnter(collision: Collision)
{
if (collision.gameObject.tag == "Bala")
{
Destroy(gameObject);
}
}
So i created that script:
#pragma strict
var helidistance : Vector3; function Start ()
{
}
function Update ()
{
helidistance = Helimovimentação.posicao - transform.position;
}
function OnCollisionEnter(collision: Collision)
{
if (collision.gameObject.tag == "Bullet")
{
Destroy (gameObject);
}
}
And the error message is that one :
Assets/Scripts/Inimigo.js(9,29): BCE0044: unexpected char: 0xE7.
Please help and thanks.
OBS: corpo.posicaoHeroi "corpo" is another script that is the hero's script, wich has a position variable like this :
var posicao : Vector3
Please format your code. You can do this by highlighting all your code, then clicking the 10101 button at the top of the edit window.
Though, it may be easier just to delete the code, paste it in again from the source, then highlight all the code and press the 101010 button at the top of the edit window before posting.
corpo.posicaoHeroi is not declared or assigned. Is this meant to be hero.position - transform.position; ?
Well I formatted your scripts as well as fixed a few errors in them. as @alucardj stated, corpo is not defined, and if 'corpo' is your second script, I'm assu$$anonymous$$g you're trying to access posicaoHeroi as a static variable, but it doesn't exist in that script. You also had some weird invalid character: 'ã' in "Helimovimentação.posicao"... These are the problems. $$anonymous$$issing variables and I'm not sure what to say about that Helimovimentação.posicao lol
Follow this Question
Related Questions
Blimp (airship) Script 0 Answers
BCE0044 Error - expecting :, found '=' 0 Answers
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Error: not a member of 'UnityEngine.GameObject[]'. 2 Answers
Objectives based on object appear. 2 Answers