ย using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class PlayerController : MonoBehaviour

{

ย  ย  Rigidbody2D rbody;

ย  ย  float axisH = 0.0f;

ย  ย  public float speed = 3.0f;

ย  ย  // Start is called before the first frame update

ย  ย  void Start()

ย  ย  {

ย  ย  ย  ย  rbody = this.GetComponent<Rigidbody2D>();

ย  ย  }


ย  ย  // Update is called once per frame

ย  ย  void Update()

ย  ย  {

ย  ย  ย  ย  axisH = Input.GetAxisRaw("Horizontal");

ย  ย  ย  ย  if (axisH > 0.0f)

ย  ย  ย  ย  {

ย  ย  ย  ย  ย  ย  Debug.Log("์˜ค๋ฅธ์ชฝ ์ด๋™");

ย  ย  ย  ย  ย  ย  transform.localScale = new Vector2(1, 1);ย 

ย  ย  ย  ย  }

ย  ย  ย  ย  else if (axisH < 0.0f)

ย  ย  ย  ย  {

ย  ย  ย  ย  ย  ย  Debug.Log("์™ผ์ชฝ์ด๋™");

ย  ย  ย  ย  ย  ย  transform.localScale = new Vector2(-1, 1);

ย  ย  ย  ย  }

ย  ย  }


ย  ย  void FixedUpdate()

ย  ย  {

ย  ย  ย  ย  rbody.velocity = new Vector2(speed * axisH, rbody.velocity.y);

ย  ย  }

}



์ด๊ฑฐ ๋ญ๊ฐ€ ๋ฌธ์ œ์ผ๊นŒ?