void FixedUpdate() { if (!attacking) { //Left if (horizontal < 0) { direction = -1; SpriteRenderer sprite = GetComponent <SpriteRenderer>(); GetComponent <Animator>().SetBool("isMoving", true); sprite.flipX = true; } //Right else if (horizontal > 0) { direction = 1; GetComponent <Animator>().SetBool("isMoving", true); SpriteRenderer sprite = GetComponent <SpriteRenderer>(); sprite.flipX = false; } //Not moving else { GetComponent <Animator>().SetBool("isMoving", false); } //fixed rate movement myBehavior.Move(new Vector2(horizontal * 5, myRigidBody.velocity.y)); } }
public void Update() { Debug.Assert(jumpBehavior != null && strategy != null, NULL_BEHAVIOR_ERR_MSG); Vector3 movementVec = strategy.Move(new Vector2(Input.GetAxis(horzInputAxisName), Input.GetAxis(vertInputAxisName))); movementVec += jumpBehavior.Jump(Input.GetButton(DEFAULT_JUMP_BTN_NAME)); }