LoginSignup
0
0

More than 3 years have passed since last update.

Unity 2D 横移動

Last updated at Posted at 2020-10-26

AキーとDキーで横移動の場合

public float speed = 1.0f;

void Update(){
    if (Input.GetKey(KeyCode.A)){
        transform.position += Vector3.left * speed * Time.deltaTime;
    }

    if (Input.GetKey(KeyCode.D)){
        transform.position -= Vector3.left * speed * Time.deltaTime;
    }
}

Unity初心者です。
もっと楽な書き方あったら教えてください!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0