public float _speed;
public bool _isRightFace = true;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update()
{
float h = Input.GetAxis("Horizontal");
transform.Translate(Vector2.right * h * _speed * Time.deltaTime);
if ((h > 0 && !_isRightFace) || (h < 0 && _isRightFace))
{
Flip(); // 시선 반전
}
}
void Flip()
{
Vector3 scale = transform.localScale;
// 스프라이트 오브젝트 돌리기
scale.x *= -1;
transform.localScale = scale;
_isRightFace = !_isRightFace;
}
그냥 케릭터 이동시키고 케릭터 이미지 방향에따라 좌우반전 생기는건데
이동이나 좌우반전 따로따로는 적용되는데
위에 코드처럼 같이쓰니까 좌우반전은 되는데 오른쪽으로만 가진다
뭐가문제냐;
애니메이터
애니메이터 안쓰는데
translate가 로컬좌표계를 기준으로 움직여서
transform.position+= 하셈