方法①:使用组件:SpriteRenderer
使用GetAxis()
和GetAxisRaw()
没有区别
public SpriteRenderer spriteRenderer;
public float moveFactor;
void Start(){
spriteRenderer=GetComponent<SpriteRenderer>();
}
void Move(){
moveFactor = Input.GetAxisRaw("Horizontal");
if(moveFactor > 0) spriteRenderer.flipX = false;
else if (moveFactor < 0) spriteRenderer.flipX = true