- Home /
Error on 'velocity = [Vector3].normalized'?
Hai guys! I'm getting a weird error I have never seen before:
Assets/SpaceShooter/Scripts/AI_BehaviorScripts/BombScript.js(27,92): BCE0044: unexpected char: 0xAD.
On the line:
velocity = moveDirection.normalized * speed;
Here's the whole script:
var speed = 5;
var rotateSpeed = 50;
var maxScanning = 40;
var blastRadius = 10;
var explosionPrefab : Transform;
private var follow = false;
private var target : Transform;
function Update ()
{
if(follow)
{
var t : Vector3 = target.transform.position;
var moveDirection : Vector3 = t - transform.position;
var velocity = rigidbody.velocity;
if(moveDirection.magnitude<1)
{
velocity = Vector3.zero;
}
else
{
velocity = moveDirection.normalized * speed;
}
rigidbody.velocity = velocity;
}
else
{
transform.Rotate(0,rotateSpeed*Time.deltaTime,0);
}
var hit : RaycastHit;
var direction = transform.TransformDirection (Vector3.forward);
if (Physics.Raycast (transform.position, direction, hit, maxScanning))
{
if(hit.collider.tag == "Player")
{
follow = true;
target = hit.collider.transform;
if(hit.distance < blastRadius)
{
//blow up and hurt the player
Destroy(gameObject);
var exp = Instantiate(explosionPrefab, transform.position, Quaternion.identity);
//this enemy is only in multiplayer
}
}
else
{
follow = false;
}
}
}
Anyone know what's going on with it?!
Answer by Owen-Reynolds · Feb 23, 2013 at 09:11 PM
Character code 0xAD isn't a proper letter. In the old days, you often got hidden, unprintable junk in your lines. In fact, cheap software protection was to name part of your program "co^w^ol^a^Ga^ume". It displayed as "coolGame," but you couldn't type the name to copy it.
Way, way back then, the fix was to completely delete the line (which deleted the invisible junk) and retype it. I haven't seen that error in a long time -- modern editors don't let you enter junk values -- but if you pasted from some oddball source, maybe.
Oh wow! I did pasted this from a youtube comment! So I just delete the line, save and retype it?