private void UpdateMoving() { // Check This character able to move if (fsmPlyer.IsAbleToMove() == false) { return; } float h = Input.GetAxisRaw("Horizontal"); float v = Input.GetAxisRaw("Vertical"); if (h == 0.0f && v == 0.0f) { fsmPlyer.SetState(CharacterBasicState.Idle, CharacterAnimationState.Idle); return; } Vector3 movement = (transform.forward * v) + (transform.right * h); CharacterAnimationState animState = CharacterAnimationState.Moving_F; bool isFrondSide = (Input.GetKey(KeyCode.W)) ? true : false; float moveAngle = Vector3.Angle(movement, transform.right); float moveSpeed = (Input.GetKey(KeyCode.W)) ? moveSpeed_forward : moveSpeed_side; //Debug.Log(moveAngle); if (180.0f <= moveAngle) { animState = CharacterAnimationState.Moving_L; } else if (135.0f <= moveAngle) { if (isFrondSide) { animState = CharacterAnimationState.Moving_FL; } else { animState = CharacterAnimationState.Moving_BL; } } else if (90.0f <= moveAngle) { if (isFrondSide) { animState = CharacterAnimationState.Moving_F; } else { animState = CharacterAnimationState.Moving_B; } } else if (45.0f <= moveAngle) { if (isFrondSide) { animState = CharacterAnimationState.Moving_FR; } else { animState = CharacterAnimationState.Moving_BR; } } else if (0.0f <= moveAngle) { animState = CharacterAnimationState.Moving_R; } movement = movement.normalized * moveSpeed * Time.fixedDeltaTime; transform.position += movement; fsmPlyer.SetState(CharacterBasicState.Moving, animState); }