I basically want to double tap the arrow/a/d key to make my character run instead of walk. I have no clue how to even begin doing this, so I'm asking for someone to either do it for me or give me an example I can embellish on.
Originally, walkspeed = 30, I want it to be 50 when I double tap.
function Update () {
if(grounded) {
moveDirection = new Vector3(0,0,Input.GetAxis("Horizontal"));
transform.LookAt(transform.position + moveDirection);
if(isMoveable == true && !isAttacking){
moveDirection *= walkSpeed;
}
if(moveDirection != Vector3.zero && isMoveable && !isAttacking){
if (Time.time - lastTime < 0.2f){
lastTime = Time.time;
walkSpeed = 30;
animation.CrossFade("run",0.1);
isMoving = true;
}else{
lastTime = Time.time;
walkSpeed = 50;
animation.CrossFade("run",0.1);
isMoving = true;
}
} else {
isMoving = false;
if(!lookingUp){
animation.CrossFade("Take 001",0.1);
}
if(lookingUp){
animation.CrossFade("idleUp",0.1);
}
}
if(Input.GetButton("Jump") && !isJumping && !isShooting && !isAttacking) {
Jump();
}
}
I would suggest starting a timer when you hit the arrow-key and if the timer is less than (let us say .50 seconds(half a second)) then make the character run.
– FLASHDENMARKhttp://forum.unity3d.com/threads/8620-Double-Tapping-axis-input
– Jessy