public void Move() { if (!Attack) { if ((GetDirection().x > 0 && transform.position.x < rightEdge.position.x) || (GetDirection().x < 0 && transform.position.x > leftEdge.position.x)) { MyAni.SetFloat("Speed", 1); transform.Translate(GetDirection() * (speed * Time.deltaTime)); } else if (currState is PatrolState) { ChangeDirection(); } else if (currState is RangedState) { Target = null; ChangeState(new IdleState()); } } }
private void HandleMovement(float horiz, float verti) { //Falling from the sky if (IsFalling) { gameObject.layer = 10; MyAni.SetBool("Land", true); } //Dodge on the ground if (!Attack && !Roll && (OnGround || airControl) && verti == 0) { dodgeSpeed = 100; MyRigi.velocity = new Vector2(horiz * speed, MyRigi.velocity.y); } //Dodge in the sky if (Jump && MyRigi.velocity.y == 0) { dodgeSpeed = .0005f; MyRigi.AddForce(new Vector2(0, jumpForce)); } if (verti > 0 && OnGround) { MyAni.SetBool("LookUp", true); } else if (verti < 0 && OnGround) { MyAni.SetBool("LookDown", true); } else { MyAni.SetBool("LookUp", false); MyAni.SetFloat("Speed", Mathf.Abs(horiz)); MyAni.SetBool("LookDown", false); } }