I have this script:
var WalkSpeedModifier : float = 8;
var WalkAnim : String = "Walk";
private var DefaultPos : Vector3;
private var Controller : CharacterController;
var PlayWhileAiming = false;
var obj = GameObject.Find("WalkAnim");
var anim = obj.GetComponent<Animation>();
function Start () {
DefaultPos = transform.localPosition;
Controller = GameObject.FindGameObjectsWithTag("Player").GetComponent(CharacterController);
}
function Update () {
if (Input.GetAxis("Vertical")||Input.GetAxis("Horizontal")) {
gameObject.animation.CrossFade(WalkAnim, 0.4);
anim[WalkAnim].speed = Controller.velocity.magnitude / WalkSpeedModifier;
}
else {
transform.localPosition = Vector3.Lerp(transform.localPosition, DefaultPos, 5);
gameObject.animation.Stop(WalkAnim);
}
if (Input.GetButton("Fire2") && PlayWhileAiming == false) {
transform.localPosition = Vector3.Lerp(transform.localPosition, DefaultPos, 5);
gameObject.animation.Stop(WalkAnim);
}
}
And it gives these errors:
Assets/Scripts/WalkAnimation.js(7,40): BCE0043: Unexpected token: ).
Assets/Scripts/WalkAnimation.js(7,41): BCE0044: expecting ), found ';'.
Assets/Scripts/WalkAnimation.js(7,42): UCE0001: ';' expected. Insert a semicolon at the end.
What am I doing wrong?