一般社団法人 全国個人事業主支援協会

COLUMN コラム

  • プログラミング5

今月のコード
Unity/C#研究中です。

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CubeMove : MonoBehaviour
{
    private float speed = 5.0f;
    void Update()
    {
      Operation();
    }
    void Operation()
    {
      if (Input.GetKey (KeyCode.UpArrow))
          transform.position += transform.up * speed * Time.deltaTime;
      if (Input.GetKey (KeyCode.DownArrow))
          transform.position -= transform.up * speed * Time.deltaTime;
      if (Input.GetKey(KeyCode.D))
          transform.position += transform.right * speed * Time.deltaTime;
      if (Input.GetKey (KeyCode.A))
          transform.position -= transform.right * speed * Time.deltaTime;
      if (Input.GetKey (KeyCode.W))
          transform.position += transform.forward * speed * Time.deltaTime;
      if (Input.GetKey (KeyCode.S))
          transform.position -= transform.forward * speed * Time.deltaTime;
    }
}
The following two tabs change content below.

user_1148

この記事をシェアする

  • Twitterでシェア
  • Facebookでシェア
  • LINEでシェア