Exemple #1
0
 private void movement()
 {
     if (Input.GetKey(KeyCode.A) && !drawRayHoriz(Vector2.left, leftRayLen, leftRaySpace))
     {
         runState = runStates.walking;
         Vector3 direction = new Vector3(transform.position.x - (.01f * currentSpeed), transform.position.y, transform.position.z);
         transform.position = direction;
         sprite.flipX       = true;
         lastDirection      = Vector2.left;
     }
     if (Input.GetKey(KeyCode.D) && !drawRayHoriz(Vector2.right, rightRayLen, rightRaySpace))
     {
         runState = runStates.walking;
         Vector3 direction = new Vector3(transform.position.x + (.01f * currentSpeed), transform.position.y, transform.position.z);
         transform.position = direction;
         sprite.flipX       = false;
         lastDirection      = Vector2.right;
     }
     if (!Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D))
     {
         runState = runStates.idle;
     }
 }
Exemple #2
0
 void Start()
 {
     airState = airborne.grounded;
     runState = runStates.idle;
 }