Created
April 29, 2016 10:58
-
-
Save makochang/dca10fb580f0036b5dfad4d2d91e65ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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