Unity 右移動左移動スクリプト

今回の記事は、Unityで、Dを押したら右移動、Aを押したら左移動する、スクリプト(処理)を書きたいと思います。
用いる言語は、C#です。まあ、Unityといえば、C#ですよね。たまに、javascript派もいますが、私はC#一筋です。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class move : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }
    //ここでスピードを変える。
    public float speed = 1.0f;
    // Update is called once per frame
    void Update()
    {
        //Aを押すと左移動する
        if (Input.GetKey(KeyCode.A))
        {
            transform.position += Vector3.left * speed * Time.deltaTime;
        }
        //Dを押すと右移動する。
        else if(Input.GetKey(KeyCode.D))
        {
            transform.position -= Vector3.left * speed * Time.deltaTime;
        }
    }
}

www.syohyodesu.info
www.syohyodesu.info