private var walkSpeed : float = 5.0;
private var jumpSpeed : float = 5.0;
private var jumpbooster : float = 25.0;
private var gravity = 100.0;
private var moveDirection : Vector3 = Vector3.zero;
private var charController : CharacterController;
static var Jumpboost: boolean = false;
var Jump : AudioClip;
function Start()
{
charController = GetComponent(CharacterController);
animation.wrapMode = WrapMode.Loop;
animation["Scuttle"].layer = -1;
animation["idle"].layer = -1;
animation.Stop();
}
function Update ()
{
if(charController.isGrounded == true)
{
animation.CrossFade("idle");
transform.eulerAngles.y += Input.GetAxis("Horizontal");
// Calculate the movement direction (forward motion)
moveDirection = Vector3(0,0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
if(Input.GetButtonDown("Jump")){
///Insert Jump here(Input.GetButton ("Jump"))
if (Jumpboost == false){
moveDirection.y = jumpSpeed;
}
if (Jumpboost ==true){
moveDirection.y = jumpbooster;
audio.PlayOneShot(Jump);
}
}
if (Input.GetKeyDown(KeyCode.UpArrow)) {
animation.CrossFade("Scuttle");
}
else if (Input.GetKeyDown(KeyCode.DownArrow)) {
animation.CrossFade("Scuttle");
}
}
moveDirection.y -= gravity * Time.deltaTime;
charController.Move(moveDirection * (Time.deltaTime * walkSpeed));
}
I can't get the animation "scuttle" to play when I press the key. Any help?