エッセイマンガ!オタクビアンカップル同棲日記「よめよめ」

同棲中のレズビアンカップルのゆんとあゆむが、日々の生活の様子をマンガや日記にしてお届けするブログです

Unity2Dゲーム制作の基本!プログラムコピペで左右移動!



 

    private float SPEED = 0.01f;

    // Start is called before the first frame update
    void Start()
    {        
    }

    // Update is called once per frame
    void Update()
    {
        Vector2 position = transform.position;

        if (Input.GetKey(KeyCode.RightArrow))
        {
            Debug.Log(position);
            position.x += SPEED;
        }
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            position.x -= SPEED;
        }

        transform.position = position;
    }