Skip to content

Instantly share code, notes, and snippets.

@makochang
Created April 29, 2016 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makochang/dca10fb580f0036b5dfad4d2d91e65ee to your computer and use it in GitHub Desktop.
Save makochang/dca10fb580f0036b5dfad4d2d91e65ee to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class Cube : MonoBehaviour
{
void Update()
{
//Wキーが押されたら、0,1,0へ移動.
if (Input.GetKeyDown(KeyCode.W))
{
GetComponent<Transform>().position = new Vector3(0.0f, 1.0f, 0.0f);
}
//Aキーが押されたら、-1,0,0へ移動.
if (Input.GetKeyDown(KeyCode.A))
{
GetComponent<Transform>().position = new Vector3(-1.0f, 0.0f, 0.0f);
}
//Sキーが押されたら、0,0,0へ移動.
if (Input.GetKeyDown(KeyCode.S))
{
GetComponent<Transform>().position = new Vector3(0.0f, 0.0f, 0.0f);
}
//Dキーが押されたら、1,0,0へ移動.
if (Input.GetKeyDown(KeyCode.D))
{
GetComponent<Transform>().position = new Vector3(1.0f, 0.0f, 0.0f);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment