What did i do wrong? ":" is wrong expression?,What did I do wrong? ":" is wrong expression

void FixedUpdate () {
var speed = 10.0;
var dir : Vector3 = Vector3.zero;

	dir.x =-Input.acceleration.y;
	dir.z = Input.acceleration.x;

		if (dir.sqrMagnitude > 1)
			dir.Normalize();

		dir*= Time.deltaTime;

	transform.Translate(dir * speed);

}

Tip: Use variable types.

Tip: Don’t multiply Vector3 * Double.

Pro tip: use {} even if it’s a line :wink:

Try this:

void FixedUpdate () {
    float speed = 10.0F;
    Vector3 dir = Vector3.zero;

    dir.x =-Input.acceleration.y;
    dir.z = Input.acceleration.x;
    if (dir.sqrMagnitude > 1){
             dir.Normalize();
	}
    dir*= Time.deltaTime;
    transform.Translate(dir * speed);
}

Well i’d imagine your use of : in “var dir : Vector3 = Vector3.zero” is wrong, but I don’t use unityscript so i don’t know how it’s supposed to be.

I understand now
Thanks :wink: